epc 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +1 -0
- data/Gemfile +22 -0
- data/Rakefile +67 -0
- data/Rakefile.gem +1 -0
- data/bin/epc +10 -0
- data/lib/epc.rb +126 -0
- data/lib/epc/client/base_client.rb +80 -0
- data/lib/epc/client/http_client.rb +19 -0
- data/lib/epc/client/json_client.rb +48 -0
- data/lib/epc/command/archive_project_command.rb +24 -0
- data/lib/epc/command/archive_solution_command.rb +21 -0
- data/lib/epc/command/attach_library_command.rb +82 -0
- data/lib/epc/command/attach_libraryset_command.rb +32 -0
- data/lib/epc/command/attach_runtime_command.rb +27 -0
- data/lib/epc/command/base_command.rb +451 -0
- data/lib/epc/command/bind_service_command.rb +35 -0
- data/lib/epc/command/build_command.rb +83 -0
- data/lib/epc/command/config/create_config_command.rb +55 -0
- data/lib/epc/command/copy_deployment_command.rb +21 -0
- data/lib/epc/command/create_command.rb +13 -0
- data/lib/epc/command/create_dependency_command.rb +43 -0
- data/lib/epc/command/define_service_command.rb +37 -0
- data/lib/epc/command/delete_config_command.rb +63 -0
- data/lib/epc/command/delete_dependency_command.rb +40 -0
- data/lib/epc/command/delete_group_command.rb +40 -0
- data/lib/epc/command/delete_library_command.rb +30 -0
- data/lib/epc/command/delete_librarylanguage_command.rb +40 -0
- data/lib/epc/command/delete_libraryset_command.rb +40 -0
- data/lib/epc/command/delete_project_command.rb +54 -0
- data/lib/epc/command/delete_role_command.rb +25 -0
- data/lib/epc/command/delete_serviceversion_command.rb +52 -0
- data/lib/epc/command/delete_solution_command.rb +39 -0
- data/lib/epc/command/delete_user_command.rb +31 -0
- data/lib/epc/command/deploy_command.rb +142 -0
- data/lib/epc/command/deployment/create_deployment_command.rb +82 -0
- data/lib/epc/command/detach_library_command.rb +35 -0
- data/lib/epc/command/detach_libraryset_command.rb +8 -0
- data/lib/epc/command/group/create_group_command.rb +21 -0
- data/lib/epc/command/info_command.rb +11 -0
- data/lib/epc/command/library/create_library_command.rb +45 -0
- data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +24 -0
- data/lib/epc/command/libraryset/create_libraryset_command.rb +54 -0
- data/lib/epc/command/list_approvals_command.rb +27 -0
- data/lib/epc/command/list_attachedlibraries_command.rb +42 -0
- data/lib/epc/command/list_boundservices_command.rb +40 -0
- data/lib/epc/command/list_config_command.rb +60 -0
- data/lib/epc/command/list_dependencies_command.rb +43 -0
- data/lib/epc/command/list_deployments_command.rb +68 -0
- data/lib/epc/command/list_groups_command.rb +19 -0
- data/lib/epc/command/list_libraries_command.rb +19 -0
- data/lib/epc/command/list_librarylanguages_command.rb +19 -0
- data/lib/epc/command/list_librarysets_command.rb +26 -0
- data/lib/epc/command/list_objectroles_command.rb +25 -0
- data/lib/epc/command/list_objecttypes_command.rb +20 -0
- data/lib/epc/command/list_permissiongroups_command.rb +20 -0
- data/lib/epc/command/list_projects_command.rb +36 -0
- data/lib/epc/command/list_projecttypes_command.rb +20 -0
- data/lib/epc/command/list_rolepermissions_command.rb +21 -0
- data/lib/epc/command/list_roles_command.rb +26 -0
- data/lib/epc/command/list_runtimes_command.rb +16 -0
- data/lib/epc/command/list_service_types_command.rb +19 -0
- data/lib/epc/command/list_servicedefinitions_command.rb +19 -0
- data/lib/epc/command/list_serviceversions_command.rb +21 -0
- data/lib/epc/command/list_solutions_command.rb +25 -0
- data/lib/epc/command/list_stages_command.rb +21 -0
- data/lib/epc/command/list_users_command.rb +26 -0
- data/lib/epc/command/list_versions_command.rb +39 -0
- data/lib/epc/command/login_command.rb +32 -0
- data/lib/epc/command/logout_command.rb +20 -0
- data/lib/epc/command/objectrole/create_objectrole_command.rb +19 -0
- data/lib/epc/command/project/create_project_command.rb +78 -0
- data/lib/epc/command/pull_command.rb +209 -0
- data/lib/epc/command/push_command.rb +194 -0
- data/lib/epc/command/refresh_solution_command.rb +71 -0
- data/lib/epc/command/renew_command.rb +19 -0
- data/lib/epc/command/request_passwordchange_command.rb +23 -0
- data/lib/epc/command/role/create_role_command.rb +17 -0
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +33 -0
- data/lib/epc/command/show_deployment_command.rb +57 -0
- data/lib/epc/command/show_group_command.rb +35 -0
- data/lib/epc/command/show_libraryset_command.rb +54 -0
- data/lib/epc/command/show_project_command.rb +74 -0
- data/lib/epc/command/show_projecttype_command.rb +18 -0
- data/lib/epc/command/show_role_command.rb +46 -0
- data/lib/epc/command/show_solution_command.rb +54 -0
- data/lib/epc/command/show_user_command.rb +42 -0
- data/lib/epc/command/solution/create_solution_command.rb +34 -0
- data/lib/epc/command/solution/list_solutions_command.rb +25 -0
- data/lib/epc/command/solution/update_solution_command.rb +43 -0
- data/lib/epc/command/submit_deployment_command.rb +19 -0
- data/lib/epc/command/target_command.rb +26 -0
- data/lib/epc/command/unarchive_project_command.rb +23 -0
- data/lib/epc/command/unarchive_solution_command.rb +21 -0
- data/lib/epc/command/unbind_service_command.rb +42 -0
- data/lib/epc/command/undefine_service_command.rb +33 -0
- data/lib/epc/command/undeploy_command.rb +106 -0
- data/lib/epc/command/update_config_command.rb +62 -0
- data/lib/epc/command/update_deploymentproject_command.rb +54 -0
- data/lib/epc/command/update_group_command.rb +43 -0
- data/lib/epc/command/update_librarylanguage_command.rb +28 -0
- data/lib/epc/command/update_libraryset_command.rb +80 -0
- data/lib/epc/command/update_project_command.rb +49 -0
- data/lib/epc/command/update_role_command.rb +47 -0
- data/lib/epc/command/update_rolepermissions_command.rb +83 -0
- data/lib/epc/command/update_solution_command.rb +45 -0
- data/lib/epc/command/update_user_command.rb +57 -0
- data/lib/epc/command/user/create_user_command.rb +27 -0
- data/lib/epc/command/vote_deployment_command.rb +29 -0
- data/lib/epc/config.rb +245 -0
- data/lib/epc/error/basic_error.rb +6 -0
- data/lib/epc/error/fatal_error.rb +6 -0
- data/lib/epc/error/input_error.rb +6 -0
- data/lib/epc/error/internal_error.rb +6 -0
- data/lib/epc/help.rb +292 -0
- data/lib/epc/persistent_attributes.rb +18 -0
- data/lib/epc/runner.rb +177 -0
- data/lib/epc/tabular_outputter.rb +161 -0
- data/lib/epc/version.rb +3 -0
- data/lib/fixnum.rb +9 -0
- data/lib/object.rb +13 -0
- data/test/command/archive_project_command_test.rb +41 -0
- data/test/command/archive_solution_command_test.rb +40 -0
- data/test/command/attach_library_command_test.rb +124 -0
- data/test/command/attach_libraryset_command_test.rb +49 -0
- data/test/command/attach_runtime_command_test.rb +44 -0
- data/test/command/base_command_test.rb +276 -0
- data/test/command/bind_service_command_test.rb +46 -0
- data/test/command/build_command_test.rb +103 -0
- data/test/command/copy_deployment_command_test.rb +38 -0
- data/test/command/create_config_command_test.rb +124 -0
- data/test/command/create_dependency_command_test.rb +55 -0
- data/test/command/create_deployment_command_test.rb +136 -0
- data/test/command/create_group_command_test.rb +34 -0
- data/test/command/create_library_command_test.rb +61 -0
- data/test/command/create_librarylanguage_command_test.rb +51 -0
- data/test/command/create_libraryset_command_test.rb +81 -0
- data/test/command/create_objectrole_command_test.rb +37 -0
- data/test/command/create_project_command_test.rb +102 -0
- data/test/command/create_role_command_test.rb +31 -0
- data/test/command/create_serviceversion_command_test.rb +60 -0
- data/test/command/create_solution_command_test.rb +70 -0
- data/test/command/create_user_command_test.rb +54 -0
- data/test/command/define_service_command_test.rb +55 -0
- data/test/command/delete_config_command_test.rb +82 -0
- data/test/command/delete_dependency_command_test.rb +50 -0
- data/test/command/delete_group_command_test.rb +56 -0
- data/test/command/delete_library_command_test.rb +43 -0
- data/test/command/delete_librarylanguage_command_test.rb +55 -0
- data/test/command/delete_libraryset_command_test.rb +55 -0
- data/test/command/delete_project_command_test.rb +76 -0
- data/test/command/delete_role_command_test.rb +41 -0
- data/test/command/delete_serviceversion_command_test.rb +53 -0
- data/test/command/delete_solution_command_test.rb +79 -0
- data/test/command/delete_user_command_test.rb +56 -0
- data/test/command/deploy_command_test.rb +185 -0
- data/test/command/detach_library_command_test.rb +53 -0
- data/test/command/info_command_test.rb +17 -0
- data/test/command/list_approvals_command_test.rb +41 -0
- data/test/command/list_boundservices_command_test.rb +46 -0
- data/test/command/list_config_command_test.rb +72 -0
- data/test/command/list_dependencies_command_test.rb +46 -0
- data/test/command/list_deployments_command_test.rb +112 -0
- data/test/command/list_deploymentstages_command_test.rb +44 -0
- data/test/command/list_libraries_command_test.rb +42 -0
- data/test/command/list_librarylanguages_command_test.rb +34 -0
- data/test/command/list_librarysets_command_test.rb +33 -0
- data/test/command/list_objectroles_command_test.rb +41 -0
- data/test/command/list_objecttypes_command_test.rb +25 -0
- data/test/command/list_permissiongroups_command_test.rb +25 -0
- data/test/command/list_projects_command_test.rb +63 -0
- data/test/command/list_projecttypes_command_test.rb +39 -0
- data/test/command/list_rolepermissions_command_test.rb +39 -0
- data/test/command/list_roles_command_test.rb +46 -0
- data/test/command/list_runtimes_command_test.rb +30 -0
- data/test/command/list_service_types_command_test.rb +44 -0
- data/test/command/list_servicedefinitions_command_test.rb +44 -0
- data/test/command/list_serviceversions_command_test.rb +47 -0
- data/test/command/list_solutions_command_test.rb +48 -0
- data/test/command/list_users_command_test.rb +33 -0
- data/test/command/login_command_test.rb +83 -0
- data/test/command/logout_command_test.rb +30 -0
- data/test/command/pull_command_test.rb +229 -0
- data/test/command/push_command_test.rb +246 -0
- data/test/command/refresh_solution_command_test.rb +35 -0
- data/test/command/renew_command_test.rb +43 -0
- data/test/command/request_passwordchange_command_test.rb +31 -0
- data/test/command/show_group_command_test.rb +50 -0
- data/test/command/show_libraryset_command_test.rb +51 -0
- data/test/command/show_project_command_test.rb +57 -0
- data/test/command/show_projecttype_command_test.rb +46 -0
- data/test/command/show_role_command_test.rb +37 -0
- data/test/command/show_solution_command_test.rb +59 -0
- data/test/command/show_user_command_test.rb +50 -0
- data/test/command/submit_deployment_command_test.rb +37 -0
- data/test/command/target_command_test.rb +58 -0
- data/test/command/unarchive_project_command_test.rb +45 -0
- data/test/command/unarchive_solution_command_test.rb +43 -0
- data/test/command/unbind_service_command_test.rb +48 -0
- data/test/command/undefine_service_command_test.rb +49 -0
- data/test/command/update_config_command_test.rb +74 -0
- data/test/command/update_deploymentproject_command_test.rb +77 -0
- data/test/command/update_group_command_test.rb +69 -0
- data/test/command/update_librarylanguage_command_test.rb +43 -0
- data/test/command/update_libraryset_command_test.rb +113 -0
- data/test/command/update_project_command_test.rb +56 -0
- data/test/command/update_role_command_test.rb +42 -0
- data/test/command/update_rolepermissions_command_test.rb +54 -0
- data/test/command/update_solution_command_test.rb +58 -0
- data/test/command/update_user_command_test.rb +76 -0
- data/test/command/vote_deployment_command_test.rb +33 -0
- data/test/config_test.rb +70 -0
- data/test/successful_test.rb +21 -0
- data/test/test_files/pom.xml +273 -0
- data/test/test_helper.rb +25 -0
- metadata +470 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateGroupCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::CreateGroupCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if no names are specified" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
assert_equal(@command.execute, 1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
should "fail if status is not 201" do
|
19
|
+
@mock_client.expects(:post).with(EPC::Config::GROUPS_PATH, {:name => "group"}).
|
20
|
+
returns([500, {:message => "System exception"}, {}])
|
21
|
+
@command.expects(:say).with("Failed to create [group] group: [System exception]")
|
22
|
+
assert_equal(@command.execute("", "group"), 500)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "request the creation of the group" do
|
26
|
+
|
27
|
+
@mock_client.expects(:post).with(EPC::Config::GROUPS_PATH, {:name => "admins"}).
|
28
|
+
returns([201, {}, {}])
|
29
|
+
@command.expects(:say).with("Group [admins] created")
|
30
|
+
|
31
|
+
assert_equal(@command.execute("", "admins"), 201)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateLibraryCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::CreateLibraryCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if arguments are not correct" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
assert_equal(@command.execute("", "lib1", "ruby"), 1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
should "determine the language id based on the name" do
|
19
|
+
@command.expects(:get_resource_id).with(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, "ruby", :case_sensitivity => false).returns(1)
|
20
|
+
@mock_client.expects(:post).returns([201, {}, {}])
|
21
|
+
@command.expects(:say)
|
22
|
+
|
23
|
+
assert_equal(@command.execute("", "lib1", "ruby", "1"), 201)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "fail if it can't determine the language id" do
|
27
|
+
@command.expects(:get_resource_id).with(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, "ruby", :case_sensitivity => false).returns(nil)
|
28
|
+
assert_raise EPC::Error::InputError do
|
29
|
+
assert_equal(@command.execute("", "lib1", "ruby", "1"), 1)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
should "fail if status is not 200" do
|
35
|
+
@mock_client.expects(:post).returns([404, {:message => "Not Found"}, {}])
|
36
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
37
|
+
|
38
|
+
assert_equal(@command.execute("", "lib1", 1, "0.2", "my_grp"), 404)
|
39
|
+
end
|
40
|
+
|
41
|
+
should "create a library" do
|
42
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARIES_PATH, {:name => "lib1", :language_id => 1, :library_version => "0.2", :group => "my_grp"}).
|
43
|
+
returns([201, {:id => 1}, {}])
|
44
|
+
@command.expects(:say).with("Created library [lib1] with ID [1]")
|
45
|
+
|
46
|
+
@command.execute("", "lib1", 1, "0.2", "my_grp")
|
47
|
+
end
|
48
|
+
|
49
|
+
context "library with a file to upload" do
|
50
|
+
should "upload the file" do
|
51
|
+
@mock_client.expects(:post).returns([201, {:id => 1, :url => "http://foo", :signature => "abc"}, {}])
|
52
|
+
@command.expects(:say).with("Created library [lib1] with ID [1]")
|
53
|
+
@command.expects(:sha1).with("/a/file")
|
54
|
+
@command.expects(:upload_library).with("/a/file", "http://foo", "abc")
|
55
|
+
@command.options[:file] ="/a/file"
|
56
|
+
assert_equal(@command.execute("", "lib1", 1, "0.2", "my_grp"), 201)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateLibrarylanguageCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::CreateLibrarylanguageCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if no names are specified" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
assert_equal(@command.execute, 1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
should "fail if status is not 201" do
|
19
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "ruby"}).
|
20
|
+
returns([500, {:message => "System exception"}, {}])
|
21
|
+
@command.expects(:say).with("Failed to create [ruby] language: [System exception]")
|
22
|
+
assert_equal(@command.execute("", "ruby"), 1)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
should "be able to create multiple libraries" do
|
27
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "ruby"}).
|
28
|
+
returns([201, {}, {}])
|
29
|
+
@command.expects(:say).with("Language [ruby] added")
|
30
|
+
|
31
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "java"}).
|
32
|
+
returns([201, {}, {}])
|
33
|
+
@command.expects(:say).with("Language [java] added")
|
34
|
+
|
35
|
+
assert_equal(@command.execute("", "ruby", "java"), 0)
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
should "continue with creation even if one request fails" do
|
40
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "ruby"}).
|
41
|
+
returns([500, {:message => "System exception"}, {}])
|
42
|
+
@command.expects(:say).with("Failed to create [ruby] language: [System exception]")
|
43
|
+
|
44
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "java"}).
|
45
|
+
returns([201, {}, {}])
|
46
|
+
@command.expects(:say).with("Language [java] added")
|
47
|
+
|
48
|
+
assert_equal(@command.execute("", "ruby", "java"), 0)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateLibrarysetCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::CreateLibrarysetCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
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
|
+
should "create the set with a language associated if one specified" do
|
27
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH, {:name => "rubylibs", :language_id => 1}).returns([201, {}, {}])
|
28
|
+
@command.expects(:say)
|
29
|
+
assert_equal(@command.execute("", "rubylibs", "1"), 201)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "retrieve the language id" do
|
33
|
+
@command.expects(:get_resource_id).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)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "fail if status is not 201" do
|
40
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH, {:name => "rubylibs", :language_id => 1}).
|
41
|
+
returns([500, {:message => "System exception"}, {}])
|
42
|
+
@command.expects(:say).with("Request failed: [System exception]")
|
43
|
+
assert_equal(@command.execute("", "rubylibs", "1"), 500)
|
44
|
+
end
|
45
|
+
|
46
|
+
should "create the set" do
|
47
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH, {:name => "rubylibs", :language_id => 1}).
|
48
|
+
returns([201, {}, {}])
|
49
|
+
@command.expects(:say).with("Set [rubylibs] created")
|
50
|
+
|
51
|
+
assert_equal(@command.execute("", "rubylibs", "1"), 201)
|
52
|
+
end
|
53
|
+
|
54
|
+
context "adding from file" do
|
55
|
+
setup do
|
56
|
+
@command.options[:file] = "/path/to/file"
|
57
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH, {:name => "rubylibs", :language_id => 1}).
|
58
|
+
returns([201, {:id => 1}, {}])
|
59
|
+
@command.expects(:say).with("Set [rubylibs] created")
|
60
|
+
end
|
61
|
+
|
62
|
+
should "retrieve ids based on name/version/group" do
|
63
|
+
EPC::Config.expects(:read_content_as_json).with("/path/to/file").returns([{"name" => "lib1", "library_version" => "1", "group" => "grp"}])
|
64
|
+
@command.expects(:retrieve_libraries).with([{:name => "lib1", :library_version => "1", :group => "grp"}]).returns([1])
|
65
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH + "/1/attach_library", :library_id => 1).returns([200, {}, {}])
|
66
|
+
@command.expects(:say).with("Library [1] added to set")
|
67
|
+
|
68
|
+
assert_equal(@command.execute("", "rubylibs", "1"), 0)
|
69
|
+
end
|
70
|
+
|
71
|
+
should "notify when a library fails to be attached" do
|
72
|
+
EPC::Config.expects(:read_content_as_json).with("/path/to/file").returns([{"name" => "lib1", "library_version" => "1", "group" => "grp"}])
|
73
|
+
@command.expects(:retrieve_libraries).with([{:name => "lib1", :library_version => "1", :group => "grp"}]).returns([1])
|
74
|
+
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH + "/1/attach_library", :library_id => 1).returns([404, {:message => "Not Found"}, {}])
|
75
|
+
@command.expects(:say).with("Failed to add [1]: [Not Found]")
|
76
|
+
|
77
|
+
assert_equal(@command.execute("", "rubylibs", "1"), 1)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateObjectroleCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::CreateObjectroleCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
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
|
+
|
24
|
+
should "request creation of the role" do
|
25
|
+
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin", :owner_id => "1", :owner_type => "Solution"}).returns([200, {}, {}])
|
26
|
+
@command.expects(:say).with("Role [Admin] created")
|
27
|
+
@command.execute("Solution:1", "Admin")
|
28
|
+
end
|
29
|
+
|
30
|
+
should "report reason for request failure" do
|
31
|
+
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin", :owner_id => "1", :owner_type => "Solution"}).returns([500, {:message => "System Exception"}, {}])
|
32
|
+
@command.expects(:say).with("Request failed: [System Exception]")
|
33
|
+
@command.execute("Solution:1", "Admin")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateProjectCommandTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
should_require_login
|
6
|
+
|
7
|
+
context "execution" do
|
8
|
+
setup do
|
9
|
+
@mock_client = mock("Client")
|
10
|
+
@command = EPC::Command::CreateProjectCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "report error if project_name is nil" do
|
14
|
+
@command.expects(:infer_solution_context).never
|
15
|
+
@mock_client.expects(:post).never
|
16
|
+
assert_raise EPC::Error::FatalError do
|
17
|
+
@command.execute(nil)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
should "fail if solution can't be infered" do
|
22
|
+
@command.options[:type] = 1
|
23
|
+
@command.expects(:infer_solution_context).returns(nil)
|
24
|
+
assert_raise EPC::Error::InputError do
|
25
|
+
assert_equal(@command.execute("", "FirstProject"), 1)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "creation" do
|
31
|
+
setup do
|
32
|
+
@mock_client = mock("Client")
|
33
|
+
@mock_config = mock("Config")
|
34
|
+
|
35
|
+
EPC::Config.target_file = '~/.epc_test_target'
|
36
|
+
@command = EPC::Command::CreateProjectCommand.new(@mock_client, {:solution_name => "FirstSolution"})
|
37
|
+
@command.options[:type] = 1
|
38
|
+
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
39
|
+
end
|
40
|
+
|
41
|
+
should "create the project directory if the status is 201" do
|
42
|
+
@command.options[:type] = "Ruby"
|
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", { :project_name => 'FirstProject', :solution_name => "FirstSolution", :uri_name => "FirstProject", :project_type_id => 1 }).
|
45
|
+
returns([201, { :id => 1, :current_version_number => 99 }, {}])
|
46
|
+
EPC::Config.expects(:write_project_metadata).with(1, @mock_client)
|
47
|
+
|
48
|
+
@command.expects(:ask_yn).returns("Y")
|
49
|
+
@command.expects(:mkdir).with("FirstProject").returns(:ok)
|
50
|
+
@command.expects(:say).with("Successfully created the project with [http://localhost:3000] and created your local directory.")
|
51
|
+
|
52
|
+
assert_equal(@command.execute("", "FirstProject"), 201)
|
53
|
+
end
|
54
|
+
|
55
|
+
should "skip directory creation if --nodir option was passed" do
|
56
|
+
@command.instance_variable_get(:@options)[:nodir] = true
|
57
|
+
|
58
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :project_name => 'FirstProject', :solution_name => "FirstSolution", :uri_name => "FirstProject", :project_type_id => 1 }).
|
59
|
+
returns([201, { :id => 1, :current_version_number => 99 }, {}])
|
60
|
+
|
61
|
+
@command.expects(:ask_yn).returns("Y")
|
62
|
+
@command.expects(:say).with("Successfully created the project with [http://localhost:3000]")
|
63
|
+
|
64
|
+
assert_equal(@command.execute("", "FirstProject"), 201)
|
65
|
+
end
|
66
|
+
|
67
|
+
should "report failure if the status is 201 and the solution directory cannot be created" do
|
68
|
+
|
69
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :project_name => 'TestProject', :solution_name => "FirstSolution", :uri_name => "TestProject", :project_type_id => 1 }).
|
70
|
+
returns([201, { :id => 1, :current_version_number => 99 }, {}])
|
71
|
+
FileUtils.expects(:mkdir).with("TestProject", {}).raises(SystemCallError.new("File exists - TestProject"))
|
72
|
+
|
73
|
+
@command.expects(:ask_yn).returns("Y")
|
74
|
+
@command.expects(:say).with("Failed to create local directory [TestProject] - [unknown error - File exists - TestProject]")
|
75
|
+
@command.expects(:say).with("Successfully created the project with [http://localhost:3000], but FAILED to create your local directory.")
|
76
|
+
|
77
|
+
assert_equal(@command.execute("", "TestProject"), 201)
|
78
|
+
end
|
79
|
+
|
80
|
+
should "report failure if the status is not 201" do
|
81
|
+
|
82
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :project_name => 'TestProject', :solution_name => "FirstSolution", :uri_name => "TestProject", :project_type_id => 1 }).
|
83
|
+
returns([400, { :message => "Bad Request" }, {}])
|
84
|
+
|
85
|
+
@command.expects(:ask_yn).returns("Y")
|
86
|
+
@command.expects(:say).with("Project creation failed [Bad Request].")
|
87
|
+
|
88
|
+
assert_equal(@command.execute("", "TestProject"), 400)
|
89
|
+
end
|
90
|
+
|
91
|
+
should "report error if the call throws an exception" do
|
92
|
+
|
93
|
+
@mock_client.expects(:post).with("/api/v1/projects", { :project_name => 'TestProject', :solution_name => "FirstSolution", :uri_name => "TestProject", :project_type_id => 1 }).
|
94
|
+
raises(StandardError.new("failed"))
|
95
|
+
|
96
|
+
@command.expects(:ask_yn).returns("Y")
|
97
|
+
@command.expects(:say).with("Project creation failed [failed].")
|
98
|
+
|
99
|
+
assert_equal(@command.execute("", "TestProject"), 1)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateRoleCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::CreateRoleCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if no role name specified" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
@command.execute
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
should "request creation of the role" do
|
19
|
+
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin"}).returns([200, {}, {}])
|
20
|
+
@command.expects(:say).with("Role [Admin] created")
|
21
|
+
@command.execute("", "Admin")
|
22
|
+
end
|
23
|
+
|
24
|
+
should "report reason for request failure" do
|
25
|
+
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin"}).returns([500, {:message => "System Exception"}, {}])
|
26
|
+
@command.expects(:say).with("Request failed: [System Exception]")
|
27
|
+
@command.execute("", "Admin")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateServiceversionCommandTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
should_require_login
|
6
|
+
|
7
|
+
context "execution" do
|
8
|
+
|
9
|
+
setup do
|
10
|
+
@mock_client = mock("Client")
|
11
|
+
@command = EPC::Command::CreateServiceversionCommand.new(@mock_client)
|
12
|
+
end
|
13
|
+
|
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
|
+
should "show a message if status is not 201" do
|
30
|
+
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :definition_id => 1, :up_script => nil, :down_script => nil}).
|
31
|
+
returns([404, {:message => "Not Found"}, {}])
|
32
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
33
|
+
|
34
|
+
assert_equal(@command.execute("", "main_db", 1), 404)
|
35
|
+
end
|
36
|
+
|
37
|
+
should "create a service version with core" do
|
38
|
+
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :definition_id => 1, :up_script => nil, :down_script => nil}).
|
39
|
+
returns([201, {}, {}])
|
40
|
+
@command.expects(:say).with("Service version successfully created.")
|
41
|
+
assert_equal(@command.execute("", "main_db", 1), 201)
|
42
|
+
end
|
43
|
+
|
44
|
+
should "allow up/down scripts" do
|
45
|
+
@command.options[:up_script] = "up_script.rb"
|
46
|
+
@command.options[:down_script] = "down_script.rb"
|
47
|
+
|
48
|
+
@command.expects(:read_file).with("up_script.rb").returns("up()")
|
49
|
+
@command.expects(:read_file).with("down_script.rb").returns("down()")
|
50
|
+
|
51
|
+
|
52
|
+
@mock_client.expects(:post).with(EPC::Config::SERVICE_VERSIONS_PATH, {:label => "main_db", :definition_id => 1, :up_script => "up()", :down_script => "down()"}).
|
53
|
+
returns([201, {}, {}])
|
54
|
+
@command.expects(:say).with("Service version successfully created.")
|
55
|
+
assert_equal(@command.execute("", "main_db", 1), 201)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|