trucker-cli 0.0.1
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.
- checksums.yaml +15 -0
- data/LICENSE +1277 -0
- data/Rakefile +13 -0
- data/bin/truck +18 -0
- data/lib/admin/README.md +30 -0
- data/lib/admin/curl.rb +59 -0
- data/lib/admin/guid.rb +89 -0
- data/lib/admin/plugin.rb +8 -0
- data/lib/admin/service_auth_token.rb +93 -0
- data/lib/admin/service_broker/add.rb +54 -0
- data/lib/admin/service_broker/remove.rb +33 -0
- data/lib/admin/service_broker/service_brokers.rb +29 -0
- data/lib/admin/service_broker/update.rb +60 -0
- data/lib/admin/set_quota.rb +44 -0
- data/lib/cf.rb +14 -0
- data/lib/cf/cli.rb +495 -0
- data/lib/cf/cli/app/app.rb +43 -0
- data/lib/cf/cli/app/apps.rb +87 -0
- data/lib/cf/cli/app/base.rb +72 -0
- data/lib/cf/cli/app/delete.rb +95 -0
- data/lib/cf/cli/app/deprecated.rb +11 -0
- data/lib/cf/cli/app/env.rb +99 -0
- data/lib/cf/cli/app/events.rb +45 -0
- data/lib/cf/cli/app/files.rb +137 -0
- data/lib/cf/cli/app/health.rb +26 -0
- data/lib/cf/cli/app/instances.rb +53 -0
- data/lib/cf/cli/app/logs.rb +76 -0
- data/lib/cf/cli/app/push.rb +104 -0
- data/lib/cf/cli/app/push/create.rb +108 -0
- data/lib/cf/cli/app/push/interactions.rb +90 -0
- data/lib/cf/cli/app/push/sync.rb +57 -0
- data/lib/cf/cli/app/rename.rb +35 -0
- data/lib/cf/cli/app/restart.rb +31 -0
- data/lib/cf/cli/app/scale.rb +63 -0
- data/lib/cf/cli/app/start.rb +175 -0
- data/lib/cf/cli/app/stats.rb +66 -0
- data/lib/cf/cli/app/stop.rb +27 -0
- data/lib/cf/cli/domain/base.rb +9 -0
- data/lib/cf/cli/domain/domains.rb +40 -0
- data/lib/cf/cli/domain/map.rb +55 -0
- data/lib/cf/cli/domain/unmap.rb +56 -0
- data/lib/cf/cli/help.rb +15 -0
- data/lib/cf/cli/interactive.rb +104 -0
- data/lib/cf/cli/login_requirements.rb +13 -0
- data/lib/cf/cli/organization/base.rb +12 -0
- data/lib/cf/cli/organization/create.rb +36 -0
- data/lib/cf/cli/organization/delete.rb +61 -0
- data/lib/cf/cli/organization/org.rb +45 -0
- data/lib/cf/cli/organization/orgs.rb +30 -0
- data/lib/cf/cli/organization/rename.rb +36 -0
- data/lib/cf/cli/populators/base.rb +16 -0
- data/lib/cf/cli/populators/organization.rb +32 -0
- data/lib/cf/cli/populators/populator_methods.rb +64 -0
- data/lib/cf/cli/populators/space.rb +33 -0
- data/lib/cf/cli/populators/target.rb +14 -0
- data/lib/cf/cli/route/base.rb +9 -0
- data/lib/cf/cli/route/delete.rb +28 -0
- data/lib/cf/cli/route/map.rb +68 -0
- data/lib/cf/cli/route/routes.rb +26 -0
- data/lib/cf/cli/route/unmap.rb +56 -0
- data/lib/cf/cli/service/base.rb +9 -0
- data/lib/cf/cli/service/bind.rb +43 -0
- data/lib/cf/cli/service/create.rb +158 -0
- data/lib/cf/cli/service/delete.rb +82 -0
- data/lib/cf/cli/service/rename.rb +35 -0
- data/lib/cf/cli/service/service.rb +40 -0
- data/lib/cf/cli/service/service_helper.rb +25 -0
- data/lib/cf/cli/service/service_instance_helper.rb +100 -0
- data/lib/cf/cli/service/services.rb +110 -0
- data/lib/cf/cli/service/unbind.rb +36 -0
- data/lib/cf/cli/space/base.rb +27 -0
- data/lib/cf/cli/space/create.rb +66 -0
- data/lib/cf/cli/space/delete.rb +55 -0
- data/lib/cf/cli/space/rename.rb +38 -0
- data/lib/cf/cli/space/space.rb +66 -0
- data/lib/cf/cli/space/spaces.rb +57 -0
- data/lib/cf/cli/space/switch.rb +18 -0
- data/lib/cf/cli/start/base.rb +35 -0
- data/lib/cf/cli/start/colors.rb +13 -0
- data/lib/cf/cli/start/login.rb +104 -0
- data/lib/cf/cli/start/logout.rb +17 -0
- data/lib/cf/cli/start/target.rb +50 -0
- data/lib/cf/cli/start/target_prettifier.rb +35 -0
- data/lib/cf/cli/start/targets.rb +16 -0
- data/lib/cf/cli/user/base.rb +29 -0
- data/lib/cf/cli/user/create.rb +51 -0
- data/lib/cf/cli/user/passwd.rb +36 -0
- data/lib/cf/cli/user/register.rb +42 -0
- data/lib/cf/cli/user/users.rb +32 -0
- data/lib/cf/constants.rb +10 -0
- data/lib/cf/errors.rb +19 -0
- data/lib/cf/plugin.rb +56 -0
- data/lib/cf/spacing.rb +89 -0
- data/lib/cf/spec_helper.rb +1 -0
- data/lib/cf/test_support.rb +6 -0
- data/lib/cf/version.rb +3 -0
- data/lib/console/README.md +16 -0
- data/lib/console/console.rb +187 -0
- data/lib/console/plugin.rb +32 -0
- data/lib/manifests/errors.rb +35 -0
- data/lib/manifests/loader.rb +31 -0
- data/lib/manifests/loader/builder.rb +39 -0
- data/lib/manifests/loader/normalizer.rb +145 -0
- data/lib/manifests/loader/resolver.rb +79 -0
- data/lib/manifests/manifests.rb +343 -0
- data/lib/manifests/plugin.rb +140 -0
- data/lib/micro/README.md +25 -0
- data/lib/micro/errors.rb +4 -0
- data/lib/micro/micro.rb +56 -0
- data/lib/micro/plugin.rb +197 -0
- data/lib/micro/switcher/base.rb +79 -0
- data/lib/micro/switcher/darwin.rb +21 -0
- data/lib/micro/switcher/dummy.rb +15 -0
- data/lib/micro/switcher/linux.rb +16 -0
- data/lib/micro/switcher/windows.rb +31 -0
- data/lib/micro/vmrun.rb +175 -0
- data/lib/tasks/gem_release.rake +56 -0
- data/lib/tasks/windows_build.rake +14 -0
- data/lib/tunnel/README.md +29 -0
- data/lib/tunnel/config/clients.yml +17 -0
- data/lib/tunnel/helper-app/Gemfile +10 -0
- data/lib/tunnel/helper-app/Gemfile.lock +48 -0
- data/lib/tunnel/helper-app/server.rb +43 -0
- data/lib/tunnel/plugin.rb +183 -0
- data/lib/tunnel/tunnel.rb +295 -0
- data/spec/admin/curl_spec.rb +52 -0
- data/spec/admin/guid_spec.rb +85 -0
- data/spec/admin/service_broker/add_spec.rb +64 -0
- data/spec/admin/service_broker/remove_spec.rb +46 -0
- data/spec/admin/service_broker/service_brokers_spec.rb +34 -0
- data/spec/admin/service_broker/update_spec.rb +51 -0
- data/spec/admin/set_quota_spec.rb +89 -0
- data/spec/assets/env/Gemfile +4 -0
- data/spec/assets/env/Gemfile.lock +20 -0
- data/spec/assets/env/env_test.rb +58 -0
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
- data/spec/assets/hello-sinatra/config.ru +3 -0
- data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
- data/spec/assets/hello-sinatra/main.rb +8 -0
- data/spec/assets/rails328_ruby187_app/Gemfile +39 -0
- data/spec/assets/rails328_ruby187_app/README.rdoc +261 -0
- data/spec/assets/rails328_ruby187_app/Rakefile +7 -0
- data/spec/assets/rails328_ruby187_app/app/assets/images/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/app/assets/javascripts/application.js +15 -0
- data/spec/assets/rails328_ruby187_app/app/assets/stylesheets/application.css +13 -0
- data/spec/assets/rails328_ruby187_app/app/controllers/application_controller.rb +3 -0
- data/spec/assets/rails328_ruby187_app/app/helpers/application_helper.rb +2 -0
- data/spec/assets/rails328_ruby187_app/app/views/layouts/application.html.erb +14 -0
- data/spec/assets/rails328_ruby187_app/config.ru +4 -0
- data/spec/assets/rails328_ruby187_app/config/application.rb +62 -0
- data/spec/assets/rails328_ruby187_app/config/boot.rb +6 -0
- data/spec/assets/rails328_ruby187_app/config/database.yml +25 -0
- data/spec/assets/rails328_ruby187_app/config/environment.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/environments/development.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/environments/production.rb +67 -0
- data/spec/assets/rails328_ruby187_app/config/environments/test.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/inflections.rb +15 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/mime_types.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/secret_token.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/session_store.rb +8 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/assets/rails328_ruby187_app/config/locales/en.yml +5 -0
- data/spec/assets/rails328_ruby187_app/config/routes.rb +58 -0
- data/spec/assets/rails328_ruby187_app/db/seeds.rb +7 -0
- data/spec/assets/rails328_ruby187_app/doc/README_FOR_APP +2 -0
- data/spec/assets/rails328_ruby187_app/manifest.yml +7 -0
- data/spec/assets/rails328_ruby187_app/public/404.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/422.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/500.html +25 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/manifest.yml +4 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/favicon.ico +0 -0
- data/spec/assets/rails328_ruby187_app/public/index.html +241 -0
- data/spec/assets/rails328_ruby187_app/public/robots.txt +5 -0
- data/spec/assets/rails328_ruby187_app/script/rails +6 -0
- data/spec/assets/rails328_ruby187_app/test/performance/browsing_test.rb +12 -0
- data/spec/assets/rails328_ruby187_app/test/test_helper.rb +13 -0
- data/spec/cf/cli/app/base_spec.rb +17 -0
- data/spec/cf/cli/app/delete_spec.rb +197 -0
- data/spec/cf/cli/app/env_spec.rb +261 -0
- data/spec/cf/cli/app/events_spec.rb +72 -0
- data/spec/cf/cli/app/help_spec.rb +39 -0
- data/spec/cf/cli/app/instances_spec.rb +69 -0
- data/spec/cf/cli/app/push/create_spec.rb +444 -0
- data/spec/cf/cli/app/push/interactions_spec.rb +32 -0
- data/spec/cf/cli/app/push_spec.rb +332 -0
- data/spec/cf/cli/app/rename_spec.rb +108 -0
- data/spec/cf/cli/app/restart_spec.rb +47 -0
- data/spec/cf/cli/app/scale_spec.rb +63 -0
- data/spec/cf/cli/app/start_spec.rb +255 -0
- data/spec/cf/cli/app/stats_spec.rb +66 -0
- data/spec/cf/cli/domain/help_spec.rb +39 -0
- data/spec/cf/cli/domain/map_spec.rb +140 -0
- data/spec/cf/cli/domain/unmap_spec.rb +77 -0
- data/spec/cf/cli/help_spec.rb +21 -0
- data/spec/cf/cli/organization/create_spec.rb +121 -0
- data/spec/cf/cli/organization/delete_spec.rb +105 -0
- data/spec/cf/cli/organization/help_spec.rb +39 -0
- data/spec/cf/cli/organization/orgs_spec.rb +116 -0
- data/spec/cf/cli/organization/rename_spec.rb +116 -0
- data/spec/cf/cli/populators/organization_spec.rb +179 -0
- data/spec/cf/cli/populators/space_spec.rb +156 -0
- data/spec/cf/cli/populators/target_spec.rb +39 -0
- data/spec/cf/cli/route/delete_spec.rb +92 -0
- data/spec/cf/cli/route/help_spec.rb +32 -0
- data/spec/cf/cli/route/map_spec.rb +148 -0
- data/spec/cf/cli/route/unmap_spec.rb +114 -0
- data/spec/cf/cli/service/bind_spec.rb +25 -0
- data/spec/cf/cli/service/create_spec.rb +147 -0
- data/spec/cf/cli/service/delete_spec.rb +22 -0
- data/spec/cf/cli/service/help_spec.rb +39 -0
- data/spec/cf/cli/service/rename_spec.rb +103 -0
- data/spec/cf/cli/service/service_helper_spec.rb +66 -0
- data/spec/cf/cli/service/service_instance_helper_spec.rb +155 -0
- data/spec/cf/cli/service/service_spec.rb +23 -0
- data/spec/cf/cli/service/services_spec.rb +156 -0
- data/spec/cf/cli/service/unbind_spec.rb +25 -0
- data/spec/cf/cli/space/base_spec.rb +49 -0
- data/spec/cf/cli/space/create_spec.rb +144 -0
- data/spec/cf/cli/space/delete_spec.rb +109 -0
- data/spec/cf/cli/space/help_spec.rb +39 -0
- data/spec/cf/cli/space/rename_spec.rb +110 -0
- data/spec/cf/cli/space/space_spec.rb +80 -0
- data/spec/cf/cli/space/spaces_spec.rb +107 -0
- data/spec/cf/cli/space/switch_space_spec.rb +57 -0
- data/spec/cf/cli/start/help_spec.rb +39 -0
- data/spec/cf/cli/start/login_spec.rb +142 -0
- data/spec/cf/cli/start/logout_spec.rb +49 -0
- data/spec/cf/cli/start/target_prettifier_spec.rb +78 -0
- data/spec/cf/cli/start/target_spec.rb +123 -0
- data/spec/cf/cli/user/create_spec.rb +98 -0
- data/spec/cf/cli/user/help_spec.rb +32 -0
- data/spec/cf/cli/user/passwd_spec.rb +94 -0
- data/spec/cf/cli/user/register_spec.rb +145 -0
- data/spec/cf/cli_spec.rb +474 -0
- data/spec/console/console_spec.rb +189 -0
- data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/clients_factory.rb +7 -0
- data/spec/factories/cfoundry/v2/domains_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/managed_service_instances_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/organizations_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/quota_definitions.rb +13 -0
- data/spec/factories/cfoundry/v2/routes_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_brokers_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_plans_factory.rb +17 -0
- data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/spaces_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/users_factory.rb +7 -0
- data/spec/features/backspace_spec.rb +46 -0
- data/spec/features/create_user_spec.rb +74 -0
- data/spec/features/delete_orphaned_service_spec.rb +64 -0
- data/spec/features/login_spec.rb +65 -0
- data/spec/features/manifests_spec.rb +86 -0
- data/spec/features/org_spec.rb +50 -0
- data/spec/features/push_flow_spec.rb +169 -0
- data/spec/features/service_brokers_spec.rb +173 -0
- data/spec/features/services_spec.rb +122 -0
- data/spec/features/space_spec.rb +107 -0
- data/spec/features/switching_targets_spec.rb +70 -0
- data/spec/manifests/errors_spec.rb +43 -0
- data/spec/manifests/loader/builder_spec.rb +80 -0
- data/spec/manifests/loader/normalizer_spec.rb +158 -0
- data/spec/manifests/manifests_spec.rb +335 -0
- data/spec/manifests/plugin_spec.rb +410 -0
- data/spec/micro/plugin_spec.rb +64 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/support/cli_helper.rb +87 -0
- data/spec/support/config_helper.rb +15 -0
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/fake_home_dir.rb +55 -0
- data/spec/support/features_helper.rb +99 -0
- data/spec/support/interact_helper.rb +27 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/mock_commands/mock_restart.rb +16 -0
- data/spec/support/mock_commands/mock_start.rb +17 -0
- data/spec/support/shared_examples/errors.rb +40 -0
- data/spec/support/shared_examples/input.rb +14 -0
- data/spec/tunnel/plugin_spec.rb +31 -0
- data/spec/tunnel/tunnel_spec.rb +54 -0
- metadata +814 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module CF
|
|
4
|
+
module Space
|
|
5
|
+
describe Create do
|
|
6
|
+
let(:client) { build(:client) }
|
|
7
|
+
before { stub_client_and_precondition }
|
|
8
|
+
|
|
9
|
+
describe "metadata" do
|
|
10
|
+
let(:command) { Mothership.commands[:create_space] }
|
|
11
|
+
|
|
12
|
+
describe "command" do
|
|
13
|
+
subject { command }
|
|
14
|
+
its(:description) { should eq "Create a space in an organization" }
|
|
15
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
include_examples "inputs must have descriptions"
|
|
19
|
+
|
|
20
|
+
describe "arguments" do
|
|
21
|
+
subject { command.arguments }
|
|
22
|
+
it "has the correct argument order" do
|
|
23
|
+
should eq([
|
|
24
|
+
{type: :optional, value: nil, name: :name},
|
|
25
|
+
{type: :optional, value: nil, name: :organization}
|
|
26
|
+
])
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "running the command" do
|
|
32
|
+
let(:new_space) { build(:space) }
|
|
33
|
+
|
|
34
|
+
before do
|
|
35
|
+
client.stub(space: new_space)
|
|
36
|
+
CF::Populators::Organization.any_instance.stub(populate_and_save!: organization)
|
|
37
|
+
|
|
38
|
+
@command_args = ["create-space", new_space.name]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context "when the space already exists" do
|
|
42
|
+
let(:existing_space) { build(:space, name: new_space.name) }
|
|
43
|
+
let(:organization) { build(:organization, spaces: [existing_space]) }
|
|
44
|
+
let(:current_user) { build(:user) }
|
|
45
|
+
|
|
46
|
+
before do
|
|
47
|
+
client.stub(current_user: current_user)
|
|
48
|
+
new_space.stub(:create!).and_raise(CFoundry::SpaceNameTaken)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "when --find-if-exists is given" do
|
|
52
|
+
before do
|
|
53
|
+
@command_args << "--find-if-exists"
|
|
54
|
+
client.stub(:space_by_name).with(new_space.name).and_return(existing_space)
|
|
55
|
+
existing_space.stub(:add_manager).with(current_user)
|
|
56
|
+
existing_space.stub(:add_developer).with(current_user)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "when --target is given" do
|
|
60
|
+
before { @command_args << "--target" }
|
|
61
|
+
|
|
62
|
+
it "switches them to the existing space" do
|
|
63
|
+
mock_invoke :target, organization: organization, space: existing_space
|
|
64
|
+
cf @command_args
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "when --target is NOT given" do
|
|
69
|
+
it "tells the user how they can switch to the existing space" do
|
|
70
|
+
cf @command_args
|
|
71
|
+
expect(output).to say("Space already exists!\n\ncf switch-space #{existing_space.name} # targets existing space")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context "when --find-if-exists is NOT given" do
|
|
77
|
+
before { @command_args << "--target" }
|
|
78
|
+
|
|
79
|
+
context "when --target is given" do
|
|
80
|
+
it "raises an exception" do
|
|
81
|
+
expect { cf @command_args }.to raise_error(CFoundry::SpaceNameTaken)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "when --target is NOT given" do
|
|
86
|
+
it "raises an exception" do
|
|
87
|
+
expect { cf @command_args }.to raise_error(CFoundry::SpaceNameTaken)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context "when the space DOES NOT already exist" do
|
|
94
|
+
let(:organization) { build(:organization, spaces: []) }
|
|
95
|
+
|
|
96
|
+
before do
|
|
97
|
+
new_space.stub(:create!)
|
|
98
|
+
new_space.stub(:add_manager)
|
|
99
|
+
new_space.stub(:add_developer)
|
|
100
|
+
new_space.stub(:add_auditor)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
context "when --find-if-exists is given" do
|
|
104
|
+
before { @command_args << "--find-if-exists" }
|
|
105
|
+
|
|
106
|
+
context "when --target is given" do
|
|
107
|
+
before { @command_args << "--target" }
|
|
108
|
+
|
|
109
|
+
it "switches them to the new space" do
|
|
110
|
+
mock_invoke :target, organization: organization, space: new_space
|
|
111
|
+
cf @command_args
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
context "when --target is NOT given" do
|
|
116
|
+
it "tells the user how they can switch to the new space" do
|
|
117
|
+
cf @command_args
|
|
118
|
+
expect(output).to say("Space created!\n\ncf switch-space #{new_space.name} # targets new space")
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
context "when --find-if-exists is NOT given" do
|
|
124
|
+
context "when --target is given" do
|
|
125
|
+
before { @command_args << "--target" }
|
|
126
|
+
|
|
127
|
+
it "switches them to the new space" do
|
|
128
|
+
mock_invoke :target, organization: organization, space: new_space
|
|
129
|
+
cf @command_args
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
context "when --target is NOT given" do
|
|
134
|
+
it "tells the user how they can switch to the new space" do
|
|
135
|
+
cf @command_args
|
|
136
|
+
expect(output).to say("Space created!\n\ncf switch-space #{new_space.name} # targets new space")
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module CF
|
|
4
|
+
module Space
|
|
5
|
+
describe Delete do
|
|
6
|
+
let(:client) { build(:client) }
|
|
7
|
+
before { stub_client_and_precondition }
|
|
8
|
+
|
|
9
|
+
describe "metadata" do
|
|
10
|
+
let(:command) { Mothership.commands[:delete_space] }
|
|
11
|
+
|
|
12
|
+
describe "command" do
|
|
13
|
+
subject { command }
|
|
14
|
+
its(:description) { should eq "Delete a space and its contents" }
|
|
15
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
include_examples "inputs must have descriptions"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "running the command" do
|
|
22
|
+
let(:space) { build :space, :name => "some_space_name" }
|
|
23
|
+
let(:organization) { build(:organization, :spaces => [space], :name => "MyOrg") }
|
|
24
|
+
|
|
25
|
+
subject { capture_output { cf %W[delete-space some_space_name --quiet --force] } }
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
|
|
29
|
+
organization.stub(:spaces_by_name).with("some_space_name").and_return([space])
|
|
30
|
+
space.stub(:delete!)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "without the force parameter when prompting" do
|
|
34
|
+
subject { cf %W[delete-space some_space_name --quiet] }
|
|
35
|
+
|
|
36
|
+
context "when the user responds 'y'" do
|
|
37
|
+
it "deletes the space, exits cleanly" do
|
|
38
|
+
space.should_receive(:delete!)
|
|
39
|
+
should_ask("Really delete #{space.name}?", {:default => false}) { true }
|
|
40
|
+
|
|
41
|
+
subject
|
|
42
|
+
@status.should == 0
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "when the user responds 'n'" do
|
|
47
|
+
it "exits cleanly without deleting the space" do
|
|
48
|
+
space.should_not_receive(:delete!)
|
|
49
|
+
should_ask("Really delete #{space.name}?", {:default => false}) { false }
|
|
50
|
+
|
|
51
|
+
subject
|
|
52
|
+
@status.should == 0
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context "when deleting the current space" do
|
|
58
|
+
before do
|
|
59
|
+
client.stub(:current_space) { space }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "warns the user what they've done" do
|
|
63
|
+
subject
|
|
64
|
+
expect(output).to say("The space that you were targeting has now been deleted. Please use `cf target -s SPACE_NAME` to target a different one.")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context "when the current space has dependent objects" do
|
|
68
|
+
before do
|
|
69
|
+
space.stub(:delete!) { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "does not print a success message" do
|
|
73
|
+
subject
|
|
74
|
+
expect(output).to_not say("The space that you were targeting has now been deleted")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "when a space fails to delete" do
|
|
80
|
+
before do
|
|
81
|
+
space.stub(:delete!) { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
|
|
82
|
+
subject
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "shows the error message" do
|
|
86
|
+
expect(output).to say "We don't delete children."
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "informs the user of how to recursively delete" do
|
|
90
|
+
expect(output).to say "If you want to delete the space along with all dependent objects, rerun the command with the '--recursive' flag."
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "returns a non-zero exit code" do
|
|
94
|
+
@status.should_not == 0
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
context "when deleting with --recursive" do
|
|
99
|
+
subject { cf %W[delete-space some_space_name --recursive --force] }
|
|
100
|
+
|
|
101
|
+
it "sends recursive true in its delete request" do
|
|
102
|
+
space.should_receive(:delete!).with(:recursive => true)
|
|
103
|
+
subject
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module CF
|
|
4
|
+
module Space
|
|
5
|
+
describe "Help" do
|
|
6
|
+
let(:global) { {} }
|
|
7
|
+
let(:given) { {} }
|
|
8
|
+
|
|
9
|
+
subject do
|
|
10
|
+
capture_output { Mothership.new.invoke(:help, :command => "space") }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "describes the command" do
|
|
14
|
+
subject
|
|
15
|
+
stdout.rewind
|
|
16
|
+
expect(stdout.readlines.first).to match /Show space information/
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "prints the options" do
|
|
20
|
+
subject
|
|
21
|
+
stdout.rewind
|
|
22
|
+
expect(stdout.readlines.any? {|line| line =~ /Options:/ }).to be_true
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context "when the user is not logged in" do
|
|
27
|
+
before do
|
|
28
|
+
capture_output { Mothership.new.invoke(:logout) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "does not require login" do
|
|
32
|
+
subject
|
|
33
|
+
stdout.rewind
|
|
34
|
+
expect(stdout.readlines.first).to_not match /Please log in first to proceed/
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module CF
|
|
4
|
+
module Space
|
|
5
|
+
describe Rename do
|
|
6
|
+
let(:client) { build(:client) }
|
|
7
|
+
let(:spaces) { Array.new(3){ build(:space) } }
|
|
8
|
+
let(:organization) { build(:organization, :spaces => spaces) }
|
|
9
|
+
let(:new_name) { "some-new-name" }
|
|
10
|
+
|
|
11
|
+
before do
|
|
12
|
+
stub_client_and_precondition
|
|
13
|
+
CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "metadata" do
|
|
17
|
+
let(:command) { Mothership.commands[:rename_space] }
|
|
18
|
+
|
|
19
|
+
describe "command" do
|
|
20
|
+
subject { command }
|
|
21
|
+
its(:description) { should eq "Rename a space" }
|
|
22
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
include_examples "inputs must have descriptions"
|
|
26
|
+
|
|
27
|
+
describe "arguments" do
|
|
28
|
+
subject { command.arguments }
|
|
29
|
+
it "has the correct argument order" do
|
|
30
|
+
should eq([
|
|
31
|
+
{:type => :optional, :value => nil, :name => :space},
|
|
32
|
+
{:type => :optional, :value => nil, :name => :name}
|
|
33
|
+
])
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "when there are no spaces" do
|
|
39
|
+
let(:spaces) { [] }
|
|
40
|
+
|
|
41
|
+
before do
|
|
42
|
+
client.stub(:spaces_by_name).with("some-invalid-space").and_return(spaces)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "and a space is given" do
|
|
46
|
+
subject { cf %W[rename-space --space some-invalid-space --no-force --no-quiet] }
|
|
47
|
+
it "prints out an error message" do
|
|
48
|
+
subject
|
|
49
|
+
expect(stderr.string).to include "Unknown space 'some-invalid-space'."
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context "and a space is not given" do
|
|
54
|
+
subject { cf %W[rename-space --no-force] }
|
|
55
|
+
it "prints out an error message" do
|
|
56
|
+
subject
|
|
57
|
+
expect(stderr.string).to include "No spaces."
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context "when there are spaces" do
|
|
63
|
+
let(:renamed_space) { spaces.first }
|
|
64
|
+
subject { cf %W[rename-space --no-force --no-quiet] }
|
|
65
|
+
|
|
66
|
+
before do
|
|
67
|
+
client.stub(:spaces_by_name).with(renamed_space.name).and_return(spaces)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context "when the defaults are used" do
|
|
71
|
+
it "asks for the space and new name and renames" do
|
|
72
|
+
should_ask("Rename which space?", anything) { renamed_space }
|
|
73
|
+
should_ask("New name") { new_name }
|
|
74
|
+
renamed_space.should_receive(:name=).with(new_name)
|
|
75
|
+
renamed_space.should_receive(:update!)
|
|
76
|
+
subject
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context "when no name is provided, but a space is" do
|
|
81
|
+
subject { cf %W[rename-space --space #{renamed_space.name} --no-force] }
|
|
82
|
+
|
|
83
|
+
it "asks for the new name and renames" do
|
|
84
|
+
dont_allow_ask("Rename which space?", anything)
|
|
85
|
+
should_ask("New name") { new_name }
|
|
86
|
+
renamed_space.should_receive(:name=).with(new_name)
|
|
87
|
+
renamed_space.should_receive(:update!)
|
|
88
|
+
subject
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context "when a space is provided and a name" do
|
|
93
|
+
subject { cf %W[rename-space --space #{renamed_space.name} --name #{new_name} --no-force] }
|
|
94
|
+
|
|
95
|
+
it "renames the space" do
|
|
96
|
+
renamed_space.should_receive(:update!)
|
|
97
|
+
subject
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "displays the progress" do
|
|
101
|
+
mock_with_progress("Renaming to #{new_name}")
|
|
102
|
+
renamed_space.should_receive(:update!)
|
|
103
|
+
|
|
104
|
+
subject
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module CF
|
|
4
|
+
module Space
|
|
5
|
+
describe Space do
|
|
6
|
+
describe "metadata" do
|
|
7
|
+
let(:command) { Mothership.commands[:space] }
|
|
8
|
+
|
|
9
|
+
describe "command" do
|
|
10
|
+
subject { command }
|
|
11
|
+
its(:description) { should eq "Show space information" }
|
|
12
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
include_examples "inputs must have descriptions"
|
|
16
|
+
|
|
17
|
+
describe "arguments" do
|
|
18
|
+
subject { command.arguments }
|
|
19
|
+
it "has the correct argument order" do
|
|
20
|
+
should eq([
|
|
21
|
+
{:type => :optional, :value => nil, :name => :space}
|
|
22
|
+
])
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "running the command" do
|
|
28
|
+
let(:client) { build(:client) }
|
|
29
|
+
|
|
30
|
+
let(:apps) { Array.new(2) { build(:app) } }
|
|
31
|
+
let(:domains) { Array.new(2) { build(:domain) } }
|
|
32
|
+
let(:services) { Array.new(2) { build(:managed_service_instance) } }
|
|
33
|
+
let(:space) { build(:space, :name => "some_space_name", :apps => apps, :service_instances => services, :domains => domains, :organization => organization ) }
|
|
34
|
+
let(:spaces) { [space] }
|
|
35
|
+
let(:organization) { build(:organization, :name => "Spacey Org") }
|
|
36
|
+
|
|
37
|
+
before do
|
|
38
|
+
stub_client_and_precondition
|
|
39
|
+
CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
|
|
40
|
+
CF::Populators::Space.any_instance.stub(:populate_and_save!).and_return(space)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "with --quiet" do
|
|
44
|
+
subject { cf %W[space some_space_name --quiet] }
|
|
45
|
+
|
|
46
|
+
it "shows only the name" do
|
|
47
|
+
subject
|
|
48
|
+
expect(stdout.read).to eq("some_space_name\n")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "with --no-quiet" do
|
|
53
|
+
subject { cf %W[space some_space_name --no-quiet] }
|
|
54
|
+
|
|
55
|
+
before { subject }
|
|
56
|
+
|
|
57
|
+
it "shows the space's name" do
|
|
58
|
+
expect(stdout.read).to include("some_space_name:")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "shows the space's org" do
|
|
62
|
+
expect(stdout.read).to include("organization: Spacey Org")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "shows apps" do
|
|
66
|
+
expect(stdout.read).to include("apps: #{apps.first.name}, #{apps.last.name}")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "shows services" do
|
|
70
|
+
expect(stdout.read).to include("services: #{services.first.name}, #{services.last.name}")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "shows domains" do
|
|
74
|
+
expect(stdout.read).to include("domains: #{domains.first.name}, #{domains.last.name}")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|