epc 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/epc.rb +25 -5
- data/lib/epc/client/json_client.rb +4 -4
- data/lib/epc/command/archive_command.rb +7 -6
- data/lib/epc/command/attachto_command.rb +13 -0
- data/lib/epc/command/base_command.rb +120 -29
- data/lib/epc/command/config/create_config_command.rb +7 -11
- data/lib/epc/command/config/delete_config_command.rb +5 -5
- data/lib/epc/command/config/list_configs_command.rb +5 -5
- data/lib/epc/command/config/update_config_command.rb +11 -10
- data/lib/epc/command/copy_command.rb +14 -0
- data/lib/epc/command/create_command.rb +9 -5
- data/lib/epc/command/delete_command.rb +9 -9
- data/lib/epc/command/{copy_deployment_command.rb → deployment/copy_deployment_command.rb} +6 -5
- data/lib/epc/command/deployment/create_deployment_command.rb +15 -15
- data/lib/epc/command/deployment/list_deployments_command.rb +2 -4
- data/lib/epc/command/deployment/show_deployment_command.rb +5 -7
- data/lib/epc/command/deployment/submit_deployment_command.rb +15 -0
- data/lib/epc/command/deployment/update_deployment_command.rb +5 -14
- data/lib/epc/command/deployment/vote_deployment_command.rb +23 -0
- data/lib/epc/command/deploymentstage/list_deploymentstages_command.rb +1 -1
- data/lib/epc/command/detachfrom_command.rb +13 -0
- data/lib/epc/command/group/create_group_command.rb +3 -3
- data/lib/epc/command/group/delete_group_command.rb +4 -5
- data/lib/epc/command/group/show_group_command.rb +2 -3
- data/lib/epc/command/group/update_group_command.rb +9 -7
- data/lib/epc/command/library/create_library_command.rb +1 -2
- data/lib/epc/command/library/delete_library_command.rb +4 -5
- data/lib/epc/command/library/list_libraries_command.rb +1 -1
- data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +1 -1
- data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +3 -5
- data/lib/epc/command/librarylanguage/list_librarylanguages_command.rb +1 -1
- data/lib/epc/command/librarylanguage/update_librarylanguage_command.rb +4 -5
- data/lib/epc/command/libraryset/create_libraryset_command.rb +5 -4
- data/lib/epc/command/libraryset/delete_libraryset_command.rb +4 -6
- data/lib/epc/command/libraryset/list_librarysets_command.rb +2 -2
- data/lib/epc/command/libraryset/show_libraryset_command.rb +3 -3
- data/lib/epc/command/libraryset/update_libraryset_command.rb +4 -3
- data/lib/epc/command/list_command.rb +10 -14
- data/lib/epc/command/list_objecttypes_command.rb +1 -1
- data/lib/epc/command/objectrole/create_objectrole_command.rb +4 -5
- data/lib/epc/command/objectrole/list_objectroles_command.rb +3 -8
- data/lib/epc/command/objectrole/update_objectrole_command.rb +3 -1
- data/lib/epc/command/permission/list_permissions_command.rb +1 -1
- data/lib/epc/command/permissiongroup/list_permissiongroups_command.rb +1 -1
- data/lib/epc/command/plugin/create_plugin_command.rb +1 -2
- data/lib/epc/command/plugin/delete_plugin_command.rb +4 -6
- data/lib/epc/command/plugin/list_plugins_command.rb +1 -1
- data/lib/epc/command/plugin/show_plugin_command.rb +2 -5
- data/lib/epc/command/plugin/update_plugin_command.rb +2 -6
- data/lib/epc/command/project/archive_project_command.rb +3 -12
- data/lib/epc/command/project/attachto_project_command.rb +133 -0
- data/lib/epc/command/project/create_project_command.rb +6 -6
- data/lib/epc/command/project/delete_project_command.rb +3 -24
- data/lib/epc/command/project/detachfrom_project_command.rb +66 -0
- data/lib/epc/command/project/list_projects_command.rb +12 -7
- data/lib/epc/command/project/show_project_command.rb +26 -25
- data/lib/epc/command/project/show_project_snapshot_command.rb +41 -0
- data/lib/epc/command/project/unarchive_project_command.rb +3 -10
- data/lib/epc/command/project/update_project_command.rb +5 -18
- data/lib/epc/command/projecttype/create_projecttype_command.rb +37 -0
- data/lib/epc/command/projecttype/delete_projecttype_command.rb +24 -0
- data/lib/epc/command/projecttype/list_projecttypes_command.rb +1 -1
- data/lib/epc/command/projecttype/show_projecttype_command.rb +2 -4
- data/lib/epc/command/projecttype/update_projecttype_command.rb +61 -0
- data/lib/epc/command/push_command.rb +14 -8
- data/lib/epc/command/role/create_role_command.rb +26 -3
- data/lib/epc/command/role/delete_role_command.rb +3 -5
- data/lib/epc/command/role/list_roles_command.rb +7 -3
- data/lib/epc/command/role/show_role_command.rb +8 -5
- data/lib/epc/command/role/update_role_command.rb +14 -66
- data/lib/epc/command/runtime/create_runtime_command.rb +34 -0
- data/lib/epc/command/runtime/delete_runtime_command.rb +24 -0
- data/lib/epc/command/runtime/list_runtimes_command.rb +2 -2
- data/lib/epc/command/runtime/update_runtime_command.rb +49 -0
- data/lib/epc/command/runtimetype/list_runtimetypes_command.rb +17 -0
- data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +5 -6
- data/lib/epc/command/servicedefinition/delete_servicedefinition_command.rb +18 -0
- data/lib/epc/command/servicedefinition/list_servicedefinitions_command.rb +2 -2
- data/lib/epc/command/servicetype/list_servicetypes_command.rb +1 -1
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +8 -12
- data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +3 -5
- data/lib/epc/command/serviceversion/list_serviceversions_command.rb +8 -1
- data/lib/epc/command/show_command.rb +8 -9
- data/lib/epc/command/show_metrics_command.rb +3 -3
- data/lib/epc/command/solution/archive_solution_command.rb +3 -10
- data/lib/epc/command/solution/create_solution_command.rb +2 -2
- data/lib/epc/command/solution/delete_solution_command.rb +3 -7
- data/lib/epc/command/solution/list_solutions_command.rb +11 -3
- data/lib/epc/command/solution/show_solution_command.rb +4 -6
- data/lib/epc/command/solution/unarchive_solution_command.rb +3 -8
- data/lib/epc/command/solution/update_solution_command.rb +4 -6
- data/lib/epc/command/submit_command.rb +16 -0
- data/lib/epc/command/unarchive_command.rb +7 -6
- data/lib/epc/command/update_command.rb +9 -8
- data/lib/epc/command/user/create_user_command.rb +2 -3
- data/lib/epc/command/user/delete_user_command.rb +3 -5
- data/lib/epc/command/user/list_users_command.rb +1 -1
- data/lib/epc/command/user/show_user_command.rb +2 -4
- data/lib/epc/command/user/update_user_command.rb +3 -14
- data/lib/epc/command/userproperty/list_user_properties_command.rb +23 -0
- data/lib/epc/command/vote_command.rb +16 -0
- data/lib/epc/config.rb +7 -1
- data/lib/epc/help.rb +51 -48
- data/lib/epc/modules/config.rb +39 -0
- data/lib/epc/modules/role.rb +133 -0
- data/lib/epc/runner.rb +23 -12
- data/lib/epc/version.rb +1 -1
- data/test/command/archive_project_command_test.rb +2 -13
- data/test/command/archive_solution_command_test.rb +4 -14
- data/test/command/copy_deployment_command_test.rb +4 -8
- data/test/command/create_config_command_test.rb +23 -23
- data/test/command/create_deployment_command_test.rb +33 -32
- data/test/command/create_group_command_test.rb +2 -2
- data/test/command/create_library_command_test.rb +6 -6
- data/test/command/create_librarylanguage_command_test.rb +3 -3
- data/test/command/create_libraryset_command_test.rb +6 -26
- data/test/command/create_objectrole_command_test.rb +4 -13
- data/test/command/create_project_command_test.rb +27 -13
- data/test/command/create_role_command_test.rb +3 -2
- data/test/command/create_runtime_command_test.rb +37 -0
- data/test/command/create_servicedefinition_command_test.rb +4 -17
- data/test/command/create_serviceversion_command_test.rb +8 -22
- data/test/command/create_solution_command_test.rb +5 -5
- data/test/command/create_user_command_test.rb +4 -4
- data/test/command/delete_config_command_test.rb +8 -15
- data/test/command/delete_library_command_test.rb +3 -4
- data/test/command/delete_librarylanguage_command_test.rb +3 -4
- data/test/command/delete_libraryset_command_test.rb +3 -4
- data/test/command/delete_plugin_command_test.rb +3 -4
- data/test/command/delete_project_command_test.rb +2 -10
- data/test/command/delete_projecttype_command_test.rb +31 -0
- data/test/command/delete_role_command_test.rb +5 -14
- data/test/command/delete_runtime_command_test.rb +31 -0
- data/test/command/delete_servicedefinition_command_test.rb +31 -0
- data/test/command/delete_serviceversion_command_test.rb +3 -2
- data/test/command/delete_solution_command_test.rb +3 -16
- data/test/command/delete_user_command_test.rb +3 -3
- data/test/command/list_config_command_test.rb +1 -0
- data/test/command/list_deployments_command_test.rb +11 -41
- data/test/command/list_objectroles_command_test.rb +4 -14
- data/test/command/list_projects_command_test.rb +0 -14
- data/test/command/list_roles_command_test.rb +3 -1
- data/test/command/list_runtimes_command_test.rb +2 -3
- data/test/command/list_runtimetypes_command_test.rb +29 -0
- data/test/command/list_userproperties_command_test.rb +33 -0
- data/test/command/push_command_test.rb +9 -1
- data/test/command/show_deployment_command_test.rb +36 -0
- data/test/command/show_group_command_test.rb +2 -1
- data/test/command/show_libraryset_command_test.rb +5 -3
- data/test/command/show_metrics_command_test.rb +4 -4
- data/test/command/show_plugin_command_test.rb +4 -4
- data/test/command/show_project_command_test.rb +5 -17
- data/test/command/show_project_snapshot_test.rb +33 -0
- data/test/command/show_projecttype_command_test.rb +5 -11
- data/test/command/show_role_command_test.rb +5 -12
- data/test/command/show_solution_command_test.rb +2 -15
- data/test/command/show_user_command_test.rb +4 -3
- data/test/command/submit_deployment_command_test.rb +4 -11
- data/test/command/unarchive_project_command_test.rb +2 -14
- data/test/command/unarchive_solution_command_test.rb +6 -16
- data/test/command/update_config_command_test.rb +14 -3
- data/test/command/update_deployment_command_test.rb +12 -26
- data/test/command/update_group_command_test.rb +2 -10
- data/test/command/update_librarylanguage_command_test.rb +5 -3
- data/test/command/update_libraryset_command_test.rb +4 -2
- data/test/command/update_plugin_command_test.rb +5 -4
- data/test/command/update_project_command_test.rb +6 -20
- data/test/command/update_role_command_test.rb +11 -8
- data/test/command/update_solution_command_test.rb +6 -12
- data/test/command/update_user_command_test.rb +3 -19
- data/test/command/vote_deployment_command_test.rb +2 -6
- metadata +66 -63
- data/lib/epc/command/attach_library_command.rb +0 -82
- data/lib/epc/command/attach_libraryset_command.rb +0 -31
- data/lib/epc/command/attach_runtime_command.rb +0 -26
- data/lib/epc/command/bind_service_command.rb +0 -35
- data/lib/epc/command/create_dependency_command.rb +0 -43
- data/lib/epc/command/dependency/delete_dependency_command.rb +0 -38
- data/lib/epc/command/detach_library_command.rb +0 -35
- data/lib/epc/command/detach_libraryset_command.rb +0 -8
- data/lib/epc/command/list_versions_command.rb +0 -38
- data/lib/epc/command/submit_deployment_command.rb +0 -19
- data/lib/epc/command/unbind_service_command.rb +0 -42
- data/lib/epc/command/undefine_service_command.rb +0 -33
- data/lib/epc/command/update_rolepermissions_command.rb +0 -83
- data/lib/epc/command/vote_deployment_command.rb +0 -29
- data/test/command/attach_library_command_test.rb +0 -124
- data/test/command/attach_libraryset_command_test.rb +0 -49
- data/test/command/attach_runtime_command_test.rb +0 -44
- data/test/command/bind_service_command_test.rb +0 -46
- data/test/command/create_dependency_command_test.rb +0 -55
- data/test/command/create_plugin_command_test.rb +0 -44
- data/test/command/delete_dependency_command_test.rb +0 -42
- data/test/command/detach_library_command_test.rb +0 -53
- data/test/command/unbind_service_command_test.rb +0 -48
- data/test/command/undefine_service_command_test.rb +0 -49
@@ -19,7 +19,7 @@ class CreateGroupCommandTest < Test::Unit::TestCase
|
|
19
19
|
@mock_client.expects(:post).with(EPC::Config::GROUPS_PATH, {:name => "group"}).
|
20
20
|
returns([500, {:message => "System exception"}, {}])
|
21
21
|
@command.expects(:say).with("Failed to create [group] group: [System exception]")
|
22
|
-
assert_equal(@command.execute("
|
22
|
+
assert_equal(@command.execute(["group"]), 500)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "request the creation of the group" do
|
@@ -28,7 +28,7 @@ class CreateGroupCommandTest < Test::Unit::TestCase
|
|
28
28
|
returns([201, {}, {}])
|
29
29
|
@command.expects(:say).with("Group [admins] created")
|
30
30
|
|
31
|
-
assert_equal(@command.execute("
|
31
|
+
assert_equal(@command.execute(["admins"]), 201)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -11,7 +11,7 @@ class CreateLibraryCommandTest < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
should "fail if arguments are not correct" do
|
13
13
|
assert_raise EPC::Error::FatalError do
|
14
|
-
assert_equal(@command.execute("
|
14
|
+
assert_equal(@command.execute(["lib1", "ruby"]), 1)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -20,13 +20,13 @@ class CreateLibraryCommandTest < Test::Unit::TestCase
|
|
20
20
|
@mock_client.expects(:post).returns([201, {}, {}])
|
21
21
|
@command.expects(:say)
|
22
22
|
|
23
|
-
assert_equal(@command.execute("
|
23
|
+
assert_equal(@command.execute(["lib1", "ruby", "1"]), 201)
|
24
24
|
end
|
25
25
|
|
26
26
|
should "fail if it can't determine the language id" do
|
27
27
|
@command.expects(:retrieve_identifier_for).returns(nil)
|
28
28
|
assert_raise EPC::Error::InputError do
|
29
|
-
assert_equal(@command.execute("
|
29
|
+
assert_equal(@command.execute(["lib1", "ruby", "1"]), 1)
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
@@ -36,7 +36,7 @@ class CreateLibraryCommandTest < Test::Unit::TestCase
|
|
36
36
|
@mock_client.expects(:post).returns([404, {:message => "Not Found"}, {}])
|
37
37
|
@command.expects(:say).with("Request failed: [Not Found]")
|
38
38
|
|
39
|
-
assert_equal(@command.execute("
|
39
|
+
assert_equal(@command.execute(["lib1", 1, "0.2", "my_grp"]), 404)
|
40
40
|
end
|
41
41
|
|
42
42
|
should "create a library" do
|
@@ -45,7 +45,7 @@ class CreateLibraryCommandTest < Test::Unit::TestCase
|
|
45
45
|
returns([201, {:id => 1}, {}])
|
46
46
|
@command.expects(:say).with("Created library [lib1] with ID [1]")
|
47
47
|
|
48
|
-
@command.execute("
|
48
|
+
@command.execute(["lib1", 1, "0.2", "my_grp"])
|
49
49
|
end
|
50
50
|
|
51
51
|
context "library with a file to upload" do
|
@@ -56,7 +56,7 @@ class CreateLibraryCommandTest < Test::Unit::TestCase
|
|
56
56
|
@command.expects(:sha1).with("/a/file")
|
57
57
|
@command.expects(:upload_library).with("/a/file", "http://foo", "abc")
|
58
58
|
@command.options[:file] ="/a/file"
|
59
|
-
assert_equal(@command.execute("
|
59
|
+
assert_equal(@command.execute(["lib1", 1, "0.2", "my_grp"]), 201)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -19,7 +19,7 @@ class CreateLibrarylanguageCommandTest < Test::Unit::TestCase
|
|
19
19
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "ruby"}).
|
20
20
|
returns([500, {:message => "System exception"}, {}])
|
21
21
|
@command.expects(:say).with("Failed to create [ruby] language: [System exception]")
|
22
|
-
assert_equal(@command.execute("
|
22
|
+
assert_equal(@command.execute(["ruby"]), 1)
|
23
23
|
end
|
24
24
|
|
25
25
|
|
@@ -32,7 +32,7 @@ class CreateLibrarylanguageCommandTest < Test::Unit::TestCase
|
|
32
32
|
returns([201, {}, {}])
|
33
33
|
@command.expects(:say).with("Language [java] added")
|
34
34
|
|
35
|
-
assert_equal(@command.execute("
|
35
|
+
assert_equal(@command.execute(["ruby", "java"]), 0)
|
36
36
|
end
|
37
37
|
|
38
38
|
|
@@ -45,7 +45,7 @@ class CreateLibrarylanguageCommandTest < Test::Unit::TestCase
|
|
45
45
|
returns([201, {}, {}])
|
46
46
|
@command.expects(:say).with("Language [java] added")
|
47
47
|
|
48
|
-
assert_equal(@command.execute("
|
48
|
+
assert_equal(@command.execute(["ruby", "java"]), 0)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -7,40 +7,20 @@ class CreateLibrarysetCommandTest < Test::Unit::TestCase
|
|
7
7
|
setup do
|
8
8
|
@mock_client = mock("Client")
|
9
9
|
@command = EPC::Command::CreateLibrarysetCommand.new(@mock_client)
|
10
|
+
@command.expects(:retrieve_identifier_for).returns(1)
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
should "fail if no name is specified" do
|
14
|
-
assert_raise EPC::Error::FatalError do
|
15
|
-
assert_equal(@command.execute(""), 1)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
should "fail if no language is specified" do
|
20
|
-
assert_raise EPC::Error::FatalError do
|
21
|
-
@command.execute("", "set")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
13
|
should "create the set with a language associated if one specified" do
|
27
14
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH, {:name => "rubylibs", :language_id => 1}).returns([201, {}, {}])
|
28
15
|
@command.expects(:say)
|
29
|
-
assert_equal(@command.execute("
|
30
|
-
end
|
31
|
-
|
32
|
-
should "retrieve the language id" do
|
33
|
-
@command.expects(:retrieve_identifier_for).returns(1)
|
34
|
-
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH, {:name => "rubylibs", :language_id => 1}).returns([201, {}, {}])
|
35
|
-
@command.expects(:say)
|
36
|
-
assert_equal(@command.execute("", "rubylibs", "ruby"), 201)
|
16
|
+
assert_equal(@command.execute(["rubylibs", "1"]), 201)
|
37
17
|
end
|
38
18
|
|
39
19
|
should "fail if status is not 201" do
|
40
20
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH, {:name => "rubylibs", :language_id => 1}).
|
41
21
|
returns([500, {:message => "System exception"}, {}])
|
42
22
|
@command.expects(:say).with("Request failed: [System exception]")
|
43
|
-
assert_equal(@command.execute("
|
23
|
+
assert_equal(@command.execute(["rubylibs", "1"]), 500)
|
44
24
|
end
|
45
25
|
|
46
26
|
should "create the set" do
|
@@ -48,7 +28,7 @@ class CreateLibrarysetCommandTest < Test::Unit::TestCase
|
|
48
28
|
returns([201, {}, {}])
|
49
29
|
@command.expects(:say).with("Set [rubylibs] created")
|
50
30
|
|
51
|
-
assert_equal(@command.execute("
|
31
|
+
assert_equal(@command.execute(["rubylibs", "1"]), 201)
|
52
32
|
end
|
53
33
|
|
54
34
|
context "adding from file" do
|
@@ -65,7 +45,7 @@ class CreateLibrarysetCommandTest < Test::Unit::TestCase
|
|
65
45
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH + "/1/attach_library", :library_id => 1).returns([200, {}, {}])
|
66
46
|
@command.expects(:say).with("Library [1] added to set")
|
67
47
|
|
68
|
-
assert_equal(@command.execute("
|
48
|
+
assert_equal(@command.execute(["rubylibs", "1"]), 0)
|
69
49
|
end
|
70
50
|
|
71
51
|
should "notify when a library fails to be attached" do
|
@@ -74,7 +54,7 @@ class CreateLibrarysetCommandTest < Test::Unit::TestCase
|
|
74
54
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH + "/1/attach_library", :library_id => 1).returns([404, {:message => "Not Found"}, {}])
|
75
55
|
@command.expects(:say).with("Failed to add [1]: [Not Found]")
|
76
56
|
|
77
|
-
assert_equal(@command.execute("
|
57
|
+
assert_equal(@command.execute(["rubylibs", "1"]), 1)
|
78
58
|
end
|
79
59
|
end
|
80
60
|
end
|
@@ -7,30 +7,21 @@ class CreateObjectroleCommandTest < Test::Unit::TestCase
|
|
7
7
|
setup do
|
8
8
|
@mock_client = mock("Client")
|
9
9
|
@command = EPC::Command::CreateObjectroleCommand.new(@mock_client)
|
10
|
+
@command.target_id = "1"
|
11
|
+
@command.target_type = "Solution"
|
10
12
|
end
|
11
13
|
|
12
|
-
should "fail if no role name and object specified" do
|
13
|
-
assert_raise EPC::Error::FatalError do
|
14
|
-
@command.execute
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
should "fail if object is not specified correctly" do
|
19
|
-
assert_raise EPC::Error::FatalError do
|
20
|
-
@command.execute("Solution", "admin")
|
21
|
-
end
|
22
|
-
end
|
23
14
|
|
24
15
|
should "request creation of the role" do
|
25
16
|
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin", :owner_id => "1", :owner_type => "Solution"}).returns([200, {}, {}])
|
26
17
|
@command.expects(:say).with("Role [Admin] created")
|
27
|
-
@command.execute("
|
18
|
+
@command.execute(["Admin"])
|
28
19
|
end
|
29
20
|
|
30
21
|
should "report reason for request failure" do
|
31
22
|
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin", :owner_id => "1", :owner_type => "Solution"}).returns([500, {:message => "System Exception"}, {}])
|
32
23
|
@command.expects(:say).with("Request failed: [System Exception]")
|
33
|
-
@command.execute("
|
24
|
+
@command.execute(["Admin"])
|
34
25
|
end
|
35
26
|
end
|
36
27
|
|
@@ -10,11 +10,11 @@ class CreateProjectCommandTest < Test::Unit::TestCase
|
|
10
10
|
@command = EPC::Command::CreateProjectCommand.new(@mock_client)
|
11
11
|
end
|
12
12
|
|
13
|
-
should "report error if
|
13
|
+
should "report error if the project name is nil" do
|
14
14
|
@command.expects(:infer_solution_context).never
|
15
15
|
@mock_client.expects(:post).never
|
16
16
|
assert_raise EPC::Error::FatalError do
|
17
|
-
@command.execute
|
17
|
+
@command.execute
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,7 +22,7 @@ class CreateProjectCommandTest < Test::Unit::TestCase
|
|
22
22
|
@command.options[:type] = 1
|
23
23
|
@command.expects(:infer_solution_context).returns(nil)
|
24
24
|
assert_raise EPC::Error::InputError do
|
25
|
-
assert_equal(@command.execute("
|
25
|
+
assert_equal(@command.execute(["FirstProject"]), 1)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -41,7 +41,7 @@ class CreateProjectCommandTest < Test::Unit::TestCase
|
|
41
41
|
should "create the project directory if the status is 201" do
|
42
42
|
@command.options[:type] = "Ruby"
|
43
43
|
@command.expects(:get_resource_id).with(EPC::Config::PROJECT_TYPES_PATH, :name, "Ruby", :case_sensitivity => false).returns(1)
|
44
|
-
@mock_client.expects(:post).with("/api/v1/projects", { :
|
44
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :name => 'FirstProject', :solution_name => "FirstSolution", :uri_name => "FirstProject", :project_type_id => 1, :runtime_memory => nil }).
|
45
45
|
returns([201, { :id => 1, :current_version_number => 99 }, {}])
|
46
46
|
EPC::Config.expects(:write_project_metadata).with(1, @mock_client)
|
47
47
|
|
@@ -49,24 +49,24 @@ class CreateProjectCommandTest < Test::Unit::TestCase
|
|
49
49
|
@command.expects(:mkdir).with("FirstProject").returns(:ok)
|
50
50
|
@command.expects(:say).with("Successfully created the project with [http://localhost:3000] and created your local directory.")
|
51
51
|
|
52
|
-
assert_equal(@command.execute("
|
52
|
+
assert_equal(@command.execute(["FirstProject"]), 201)
|
53
53
|
end
|
54
54
|
|
55
55
|
should "skip directory creation if --nodir option was passed" do
|
56
56
|
@command.instance_variable_get(:@options)[:nodir] = true
|
57
57
|
|
58
|
-
@mock_client.expects(:post).with("/api/v1/projects", { :
|
58
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :name => 'FirstProject', :solution_name => "FirstSolution", :uri_name => "FirstProject", :project_type_id => 1, :runtime_memory => nil }).
|
59
59
|
returns([201, { :id => 1, :current_version_number => 99 }, {}])
|
60
60
|
|
61
61
|
@command.expects(:ask_yn).returns("Y")
|
62
62
|
@command.expects(:say).with("Successfully created the project with [http://localhost:3000]")
|
63
63
|
|
64
|
-
assert_equal(@command.execute("
|
64
|
+
assert_equal(@command.execute(["FirstProject"]), 201)
|
65
65
|
end
|
66
66
|
|
67
67
|
should "report failure if the status is 201 and the solution directory cannot be created" do
|
68
68
|
|
69
|
-
@mock_client.expects(:post).with("/api/v1/projects", { :
|
69
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :name => 'TestProject', :solution_name => "FirstSolution", :uri_name => "TestProject", :project_type_id => 1, :runtime_memory => nil }).
|
70
70
|
returns([201, { :id => 1, :current_version_number => 99 }, {}])
|
71
71
|
FileUtils.expects(:mkdir).with("TestProject", {}).raises(SystemCallError.new("File exists - TestProject"))
|
72
72
|
|
@@ -74,29 +74,43 @@ class CreateProjectCommandTest < Test::Unit::TestCase
|
|
74
74
|
@command.expects(:say).with("Failed to create local directory [TestProject] - [unknown error - File exists - TestProject]")
|
75
75
|
@command.expects(:say).with("Successfully created the project with [http://localhost:3000], but FAILED to create your local directory.")
|
76
76
|
|
77
|
-
assert_equal(@command.execute("
|
77
|
+
assert_equal(@command.execute(["TestProject"]), 201)
|
78
|
+
end
|
79
|
+
|
80
|
+
should "send the runtime memory when supplied" do
|
81
|
+
@command.options[:type] = "Ruby"
|
82
|
+
@command.expects(:get_resource_id).with(EPC::Config::PROJECT_TYPES_PATH, :name, "Ruby", :case_sensitivity => false).returns(1)
|
83
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :name => 'FirstProject', :solution_name => "FirstSolution", :uri_name => "FirstProject", :project_type_id => 1, :runtime_memory => 128 }).
|
84
|
+
returns([201, { :id => 1, :current_version_number => 99 }, {}])
|
85
|
+
EPC::Config.expects(:write_project_metadata).with(1, @mock_client)
|
86
|
+
|
87
|
+
@command.expects(:ask_yn).returns("Y")
|
88
|
+
@command.expects(:mkdir).with("FirstProject").returns(:ok)
|
89
|
+
@command.expects(:say).with("Successfully created the project with [http://localhost:3000] and created your local directory.")
|
90
|
+
|
91
|
+
assert_equal(@command.execute(["FirstProject",nil,128]), 201)
|
78
92
|
end
|
79
93
|
|
80
94
|
should "report failure if the status is not 201" do
|
81
95
|
|
82
|
-
@mock_client.expects(:post).with("/api/v1/projects", { :
|
96
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :name => 'TestProject', :solution_name => "FirstSolution", :uri_name => "TestProject", :project_type_id => 1, :runtime_memory => nil }).
|
83
97
|
returns([400, { :message => "Bad Request" }, {}])
|
84
98
|
|
85
99
|
@command.expects(:ask_yn).returns("Y")
|
86
100
|
@command.expects(:say).with("Project creation failed [Bad Request].")
|
87
101
|
|
88
|
-
assert_equal(@command.execute("
|
102
|
+
assert_equal(@command.execute(["TestProject"]), 400)
|
89
103
|
end
|
90
104
|
|
91
105
|
should "report error if the call throws an exception" do
|
92
106
|
|
93
|
-
@mock_client.expects(:post).with("/api/v1/projects", { :
|
107
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :name => 'TestProject', :solution_name => "FirstSolution", :uri_name => "TestProject", :project_type_id => 1, :runtime_memory => nil }).
|
94
108
|
raises(StandardError.new("failed"))
|
95
109
|
|
96
110
|
@command.expects(:ask_yn).returns("Y")
|
97
111
|
@command.expects(:say).with("Project creation failed [failed].")
|
98
112
|
|
99
|
-
assert_equal(@command.execute("
|
113
|
+
assert_equal(@command.execute(["TestProject"]), 1)
|
100
114
|
end
|
101
115
|
end
|
102
116
|
end
|
@@ -6,6 +6,7 @@ class CreateRoleCommandTest < Test::Unit::TestCase
|
|
6
6
|
context "execute" do
|
7
7
|
setup do
|
8
8
|
@mock_client = mock("Client")
|
9
|
+
EPC::Command::CreateRoleCommand.send :include, EPC::Command::Role
|
9
10
|
@command = EPC::Command::CreateRoleCommand.new(@mock_client)
|
10
11
|
end
|
11
12
|
|
@@ -18,13 +19,13 @@ class CreateRoleCommandTest < Test::Unit::TestCase
|
|
18
19
|
should "request creation of the role" do
|
19
20
|
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin"}).returns([200, {}, {}])
|
20
21
|
@command.expects(:say).with("Role [Admin] created")
|
21
|
-
@command.execute("
|
22
|
+
@command.execute(["Admin"])
|
22
23
|
end
|
23
24
|
|
24
25
|
should "report reason for request failure" do
|
25
26
|
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin"}).returns([500, {:message => "System Exception"}, {}])
|
26
27
|
@command.expects(:say).with("Request failed: [System Exception]")
|
27
|
-
@command.execute("
|
28
|
+
@command.execute(["Admin"])
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateRuntimeCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::CreateRuntimeCommand.new(@mock_client)
|
10
|
+
@command.target_id = 1
|
11
|
+
@command.target_type = "RuntimeType"
|
12
|
+
end
|
13
|
+
|
14
|
+
should "fail if mandatory attributes not specified" do
|
15
|
+
assert_raise EPC::Error::FatalError do
|
16
|
+
@command.execute
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
should "request creation of the runtime" do
|
21
|
+
@command.expects(:retrieve_identifier_for).returns(1)
|
22
|
+
@mock_client.expects(:post).with(EPC::Config::RUNTIMES_PATH, {:name => "runtime", :target => "runtime_target", :runtime_env_type_id => 1, :deployment_stage_id => 1, :username => "user", :password => "pass"}).returns([200, {}, {}])
|
23
|
+
@command.expects(:say).with("Runtime [runtime] created")
|
24
|
+
@command.execute(["runtime", "runtime_target", "Development", "user", "pass" ])
|
25
|
+
end
|
26
|
+
|
27
|
+
should "report reason for request failure" do
|
28
|
+
@command.expects(:retrieve_identifier_for).returns(1)
|
29
|
+
@mock_client.expects(:post).with(EPC::Config::RUNTIMES_PATH, {:name => "runtime", :target => "runtime_target", :runtime_env_type_id => 1, :deployment_stage_id => 1, :username => "user", :password => "pass"}).returns([500, {:message => "System Exception"}, {}])
|
30
|
+
@command.expects(:say).with("Request failed: [System Exception]")
|
31
|
+
@command.execute(["runtime", "runtime_target", "Development", "user", "pass" ])
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
@@ -6,37 +6,24 @@ require 'mocha'
|
|
6
6
|
class CreateServicedefinitionCommandTest < Test::Unit::TestCase
|
7
7
|
should_require_login
|
8
8
|
|
9
|
-
context "execution" do
|
10
|
-
setup do
|
11
|
-
@mock_client = mock('Client')
|
12
|
-
end
|
13
|
-
|
14
|
-
should "require both the name and service type" do
|
15
|
-
@command = EPC::Command::CreateServicedefinitionCommand.new(@mock_client)
|
16
|
-
assert_raise EPC::Error::FatalError do
|
17
|
-
@command.execute("")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
9
|
context "service definition" do
|
24
10
|
setup do
|
25
11
|
@mock_client = stub('Client')
|
26
12
|
@command = EPC::Command::CreateServicedefinitionCommand.new(@mock_client, {:service_type => "MySQL"})
|
27
|
-
@command.
|
13
|
+
@command.target_id = 1
|
14
|
+
@command.target_type = "ServiceVersion"
|
28
15
|
end
|
29
16
|
|
30
17
|
should "fail if status is not 201" do
|
31
18
|
@mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([400, {:message => 'Not Found'}])
|
32
19
|
@command.expects(:say).with("Service definition failed with: [Not Found]")
|
33
|
-
@command.execute("
|
20
|
+
@command.execute(["service", "MySQL"])
|
34
21
|
end
|
35
22
|
|
36
23
|
should "define a service" do
|
37
24
|
@mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([201, {'id' => 1}])
|
38
25
|
@command.expects(:say).with("service has been defined.")
|
39
|
-
@command.execute("
|
26
|
+
@command.execute(["service", "MySQL"])
|
40
27
|
end
|
41
28
|
end
|
42
29
|
end
|
@@ -9,36 +9,23 @@ class CreateServiceversionCommandTest < Test::Unit::TestCase
|
|
9
9
|
setup do
|
10
10
|
@mock_client = mock("Client")
|
11
11
|
@command = EPC::Command::CreateServiceversionCommand.new(@mock_client)
|
12
|
+
@command.target_id = 1
|
13
|
+
@command.target_type = "ServiceDefinition"
|
12
14
|
end
|
13
15
|
|
14
|
-
should "require the user to input label and service definition" do
|
15
|
-
|
16
|
-
assert_raise EPC::Error::FatalError do
|
17
|
-
assert_equal(@command.execute(""), 1)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
should "query for the definition id and notify the user if it wasn't found" do
|
22
|
-
@command.expects(:get_resource_id).returns(nil)
|
23
|
-
assert_raise EPC::Error::InputError do
|
24
|
-
assert_equal(@command.execute("", "main_db", "mysql"), 1)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
16
|
should "show a message if status is not 201" do
|
30
|
-
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :
|
17
|
+
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :service_definition_id => 1, :up_script => nil, :down_script => nil, :backwards_compatible => "false", :reversible => "false"}).
|
31
18
|
returns([404, {:message => "Not Found"}, {}])
|
32
19
|
@command.expects(:say).with("Request failed: [Not Found]")
|
33
20
|
|
34
|
-
assert_equal(@command.execute("
|
21
|
+
assert_equal(@command.execute(["main_db"]), 404)
|
35
22
|
end
|
36
23
|
|
37
24
|
should "create a service version with core" do
|
38
|
-
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :
|
25
|
+
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :service_definition_id => 1, :up_script => nil, :down_script => nil, :backwards_compatible => "false", :reversible => "false"}).
|
39
26
|
returns([201, {}, {}])
|
40
27
|
@command.expects(:say).with("Service version successfully created.")
|
41
|
-
assert_equal(@command.execute("
|
28
|
+
assert_equal(@command.execute(["main_db"]), 201)
|
42
29
|
end
|
43
30
|
|
44
31
|
should "allow up/down scripts" do
|
@@ -49,12 +36,11 @@ class CreateServiceversionCommandTest < Test::Unit::TestCase
|
|
49
36
|
@command.expects(:read_file).with("down_script.rb").returns("down()")
|
50
37
|
|
51
38
|
|
52
|
-
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :
|
39
|
+
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :service_definition_id => 1, :up_script => "up()", :down_script => "down()", :backwards_compatible => 'false', :reversible => "false"}).
|
53
40
|
returns([201, {}, {}])
|
54
41
|
@command.expects(:say).with("Service version successfully created.")
|
55
|
-
assert_equal(@command.execute("
|
42
|
+
assert_equal(@command.execute(["main_db"]), 201)
|
56
43
|
end
|
57
44
|
|
58
45
|
end
|
59
46
|
end
|
60
|
-
|