trucker-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ServiceHelper do
|
4
|
+
describe "#label" do
|
5
|
+
it "returns the label for the service" do
|
6
|
+
service = build(:service, label: 'mysql')
|
7
|
+
helper = ServiceHelper.new(service)
|
8
|
+
|
9
|
+
expect(helper.label).to eq('mysql')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#provider" do
|
14
|
+
it "returns the provider for the service if it has one" do
|
15
|
+
service = build(:service, provider: 'aws')
|
16
|
+
helper = ServiceHelper.new(service)
|
17
|
+
|
18
|
+
expect(helper.provider).to eq('aws')
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns n/a if it does not have a provider" do
|
22
|
+
service = build(:service, provider: nil)
|
23
|
+
helper = ServiceHelper.new(service)
|
24
|
+
|
25
|
+
expect(helper.provider).to eq('n/a')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#version" do
|
30
|
+
it "returns the version for the service if it has one" do
|
31
|
+
service = build(:service, version: '3.11')
|
32
|
+
helper = ServiceHelper.new(service)
|
33
|
+
|
34
|
+
expect(helper.version).to eq('3.11')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns n/a if it does not have a version" do
|
38
|
+
service = build(:service, version: nil)
|
39
|
+
helper = ServiceHelper.new(service)
|
40
|
+
|
41
|
+
expect(helper.version).to eq('n/a')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#service_plans" do
|
46
|
+
it "returns the plans for the service if it has one" do
|
47
|
+
plans = [
|
48
|
+
build(:service_plan, name: 'small'),
|
49
|
+
build(:service_plan, name: 'large')
|
50
|
+
]
|
51
|
+
service = build(:service, :service_plans => plans)
|
52
|
+
helper = ServiceHelper.new(service)
|
53
|
+
|
54
|
+
expect(helper.service_plans).to eq('small, large')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#description" do
|
59
|
+
it "returns the plans for the service if it has one" do
|
60
|
+
service = build(:service, :description => 'super awesome NoSQL NO DOWNTIME')
|
61
|
+
helper = ServiceHelper.new(service)
|
62
|
+
|
63
|
+
expect(helper.description).to eq('super awesome NoSQL NO DOWNTIME')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ServiceInstanceHelper do
|
4
|
+
describe ".new" do
|
5
|
+
let(:provided_instance) { build(:user_provided_service_instance) }
|
6
|
+
let(:managed_instance) { build(:managed_service_instance) }
|
7
|
+
|
8
|
+
it "returns a ManagedServiceInstanceHelper when the argument is a ManagedServiceInstance" do
|
9
|
+
expect(ServiceInstanceHelper.new(managed_instance)).to be_a ManagedServiceInstanceHelper
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns a ManagedSerivceInstanceHelper when the argument is a ManagedServiceInstance" do
|
13
|
+
expect(ServiceInstanceHelper.new(provided_instance)).to be_a UserProvidedServiceInstanceHelper
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe UserProvidedServiceInstanceHelper do
|
19
|
+
let(:bindings) { [] }
|
20
|
+
let(:instance) { build(:user_provided_service_instance, service_bindings: bindings) }
|
21
|
+
subject(:helper) { UserProvidedServiceInstanceHelper.new(instance) }
|
22
|
+
describe "matches" do
|
23
|
+
it "returns true when 'user-provided' is the given label" do
|
24
|
+
expect(helper.matches(service: "user-provided")).to eq true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns false when 'user-provided' is not the given label" do
|
28
|
+
expect(helper.matches(service: "a-different-label")).to eq false
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns true when a label is not given" do
|
32
|
+
expect(helper.matches).to eq true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
its(:service_label) { should eq("user-provided") }
|
37
|
+
its(:service_provider) { should eq("n/a") }
|
38
|
+
its(:version) { should eq("n/a") }
|
39
|
+
its(:plan_name) { should eq("n/a") }
|
40
|
+
its(:name) { should eq instance.name }
|
41
|
+
its(:service_bindings) { should eq instance.service_bindings }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ManagedServiceInstanceHelper do
|
45
|
+
let(:label) { "some-label" }
|
46
|
+
let(:provider) { "some-provider" }
|
47
|
+
let(:version) { "some-version" }
|
48
|
+
let(:plan_name) { "some-plan-name" }
|
49
|
+
|
50
|
+
let(:service) { build(:service, label: label, provider: provider, version: version) }
|
51
|
+
let(:plan) { build(:service_plan, service: service, name: plan_name) }
|
52
|
+
let(:bindings) { [] }
|
53
|
+
let(:instance) { build(:managed_service_instance, service_plan: plan, service_bindings: bindings) }
|
54
|
+
subject(:helper) { ManagedServiceInstanceHelper.new(instance) }
|
55
|
+
|
56
|
+
describe "matches" do
|
57
|
+
it "returns true when no condition is specified" do
|
58
|
+
expect(helper.matches).to eq(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
context "filtering based on service" do
|
62
|
+
it "returns true if the service label matches given service" do
|
63
|
+
expect(helper.matches(service: label)).to eq(true)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns false if the service label does not match given service" do
|
67
|
+
expect(helper.matches(service: "a-different-label")).to eq(false)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "filtering based on service plan" do
|
72
|
+
it "returns true if the plan name matches given plan" do
|
73
|
+
expect(helper.matches(plan: plan_name)).to eq(true)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "returns true if the plan name does not match given plan" do
|
77
|
+
expect(helper.matches(plan: "some-other-plan-name")).to eq(false)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "is case insensitive" do
|
81
|
+
expect(helper.matches(plan: plan_name.upcase)).to eq(true)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "filtering based on provider" do
|
86
|
+
it "returns true if the provider name matches given provider" do
|
87
|
+
expect(helper.matches(provider: provider)).to eq(true)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "returns true if the provider does not match given provider" do
|
91
|
+
expect(helper.matches(provider: "a-different-provider")).to eq(false)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "filtering based on version" do
|
96
|
+
it "returns true if the version matches given version" do
|
97
|
+
expect(helper.matches(version: version)).to eq(true)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns true if the version does not match given version" do
|
101
|
+
expect(helper.matches(version: "a-different-version")).to eq(false)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context "multiple filters" do
|
106
|
+
it "returns true if the service instance matches all four parameters" do
|
107
|
+
expect(helper.matches(service: label, plan: plan_name,
|
108
|
+
provider: provider, version: version)).to eq true
|
109
|
+
end
|
110
|
+
|
111
|
+
it "return false if any of the parameters does not match the attribute of the service instance" do
|
112
|
+
expect(helper.matches(service: label, plan: plan_name,
|
113
|
+
provider: provider, version: "a-different-version")).to eq false
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "with patterns for args" do
|
118
|
+
it "returns true when service label matches the given glob" do
|
119
|
+
expect(helper.matches(service: label.gsub(/.$/, "*"))).to eq(true)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "returns false when the service label doesn not match the given glob" do
|
123
|
+
expect(helper.matches(service: label + "_*")).to eq(false)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "service_label" do
|
129
|
+
|
130
|
+
it "returns the label of instance's service offering" do
|
131
|
+
expect(helper.service_label).to eq label
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "service_provider" do
|
136
|
+
it "returns the provider of the instance's service offering" do
|
137
|
+
expect(helper.service_provider).to eq provider
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "version" do
|
142
|
+
it "returns the version of the instance's service offering" do
|
143
|
+
expect(helper.version).to eq version
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "plan_name" do
|
148
|
+
it "returns the name of the instance's service plan" do
|
149
|
+
expect(helper.plan_name).to eq plan_name
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
its(:name) { should eq instance.name }
|
154
|
+
its(:service_bindings) { should eq instance.service_bindings }
|
155
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CF::Service::Service do
|
4
|
+
describe 'metadata' do
|
5
|
+
let(:command) { Mothership.commands[:service] }
|
6
|
+
|
7
|
+
describe 'command' do
|
8
|
+
subject { command }
|
9
|
+
its(:description) { should eq "Show service information" }
|
10
|
+
it { expect(Mothership::Help.group(:services)).to include(subject) }
|
11
|
+
end
|
12
|
+
|
13
|
+
include_examples 'inputs must have descriptions'
|
14
|
+
|
15
|
+
describe 'arguments' do
|
16
|
+
subject { command.arguments }
|
17
|
+
it 'has the correct argument order' do
|
18
|
+
should eq([{:type => :required, :value=>nil, :name=>:service}])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module Service
|
5
|
+
describe Services do
|
6
|
+
let(:command) { Mothership.commands[:services] }
|
7
|
+
|
8
|
+
describe "metadata" do
|
9
|
+
describe "command" do
|
10
|
+
subject { command }
|
11
|
+
its(:description) { should eq "List your services" }
|
12
|
+
it { expect(Mothership::Help.group(:services)).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 no required arguments" do
|
20
|
+
should eq([])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "inputs" do
|
25
|
+
subject { command.inputs }
|
26
|
+
it "has the expected inputs" do
|
27
|
+
subject.keys.should =~ [:name, :service, :marketplace, :plan, :provider, :version, :app, :full, :space]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "listing services" do
|
33
|
+
let(:global) { {:color => false} }
|
34
|
+
let(:inputs) { {} }
|
35
|
+
let(:given) { {} }
|
36
|
+
let(:client) do
|
37
|
+
build(:client).tap do |client|
|
38
|
+
client.stub(:current_space => current_space, :service_instances => service_instances)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
let(:app) { build(:app) }
|
42
|
+
|
43
|
+
let(:service_plan) { build(:service_plan, :service => build(:service, :version => "service_version", :provider => "provider")) }
|
44
|
+
let(:service_binding) { build(:service_binding, :app => app) }
|
45
|
+
let(:service1) { build(:managed_service_instance, :service_plan => service_plan, :service_bindings => [service_binding]) }
|
46
|
+
|
47
|
+
let(:service_instances) { [service1] }
|
48
|
+
let(:current_space) { build(:space, :name => "the space") }
|
49
|
+
|
50
|
+
subject do
|
51
|
+
capture_output { CF::CLI.new.invoke(:services, inputs, given, global) }
|
52
|
+
end
|
53
|
+
|
54
|
+
before do
|
55
|
+
stub_client
|
56
|
+
client.stub(:service_bindings).and_return([service_binding])
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when the user is targeted to a space" do
|
60
|
+
before do
|
61
|
+
stub_precondition
|
62
|
+
end
|
63
|
+
|
64
|
+
it "produces a table of services" do
|
65
|
+
subject
|
66
|
+
stdout.rewind
|
67
|
+
output = stdout.read
|
68
|
+
|
69
|
+
expect(output).to match /Getting services in the space.*OK/
|
70
|
+
|
71
|
+
expect(output).to match /name\s+service\s+provider\s+version\s+plan\s+bound apps/
|
72
|
+
expect(output).to match /service-instance-.+?\s+ # name
|
73
|
+
service-.*?\s+ # service
|
74
|
+
provider.*?\s+ # provider
|
75
|
+
service_version\s+ # version
|
76
|
+
service-plan-.*?\s+ # plan
|
77
|
+
app-name-\d+\s+ # bound apps
|
78
|
+
/x
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
context "when one of the services does not have a service plan" do
|
83
|
+
let(:service_instances) { [service1, service2]}
|
84
|
+
let(:service2) { build(:user_provided_service_instance, :service_bindings => [service_binding]) }
|
85
|
+
|
86
|
+
it 'still produces a table of service' do
|
87
|
+
subject
|
88
|
+
stdout.rewind
|
89
|
+
output = stdout.read
|
90
|
+
|
91
|
+
expect(output).to match /Getting services in the space.*OK/
|
92
|
+
|
93
|
+
expect(output).to match /name\s+service\s+provider\s+version\s+plan\s+bound apps/
|
94
|
+
|
95
|
+
expect(output).to match /service-instance-.+?\s+ # name
|
96
|
+
service-.*?\s+ # service
|
97
|
+
provider.*?\s+ # provider
|
98
|
+
service_version\s+ # version
|
99
|
+
service-plan-.*?\s+ # plan
|
100
|
+
app-name-\d+\s+ # bound apps
|
101
|
+
/x
|
102
|
+
|
103
|
+
expect(output).to match /service-instance-.+?\s+ # name
|
104
|
+
user-provided\s+ # service
|
105
|
+
n\/a\s+ # provider
|
106
|
+
n\/a\s+ # version
|
107
|
+
n\/a\s+ # plan
|
108
|
+
app-name-\d+\s+ # bound apps
|
109
|
+
/x
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when given --marketplace argument' do
|
114
|
+
it 'lists services on the target' do
|
115
|
+
client.stub(:services => Array.new(3) { build(:service) })
|
116
|
+
cf %W[services --marketplace]
|
117
|
+
expect(output).to say("Getting services... OK")
|
118
|
+
expect(output).to say(/service\s+version\s+provider\s+plans\s+description/)
|
119
|
+
end
|
120
|
+
|
121
|
+
context "when one of the services does not have a version or provider" do
|
122
|
+
it 'replaces those fields with n/a' do
|
123
|
+
client.stub(:services => [build(:service, :version => nil, :provider => nil)])
|
124
|
+
cf %W[services --marketplace]
|
125
|
+
expect(output).to say(/n\/a\s+n\/a/)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context "when the user is not targeted to a space" do
|
132
|
+
before do
|
133
|
+
service_command.stub(:check_logged_in).and_return(true)
|
134
|
+
client.stub(:current_organization).and_return(true)
|
135
|
+
end
|
136
|
+
let(:service_command) { CF::Service::Services.new(nil, {}) }
|
137
|
+
let(:current_space) { nil }
|
138
|
+
|
139
|
+
subject do
|
140
|
+
capture_output { service_command.execute(:services, inputs, global) }
|
141
|
+
|
142
|
+
#capture_output { CF::CLI.new.invoke(:services, inputs, given, global) }
|
143
|
+
end
|
144
|
+
|
145
|
+
it "returns an error" do
|
146
|
+
subject
|
147
|
+
stdout.rewind
|
148
|
+
output = stderr.read
|
149
|
+
|
150
|
+
expect(output.to_s).to match "Please select a space with 'truck target --space SPACE_NAME'"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CF::Service::Unbind do
|
4
|
+
describe 'metadata' do
|
5
|
+
let(:command) { Mothership.commands[:unbind_service] }
|
6
|
+
|
7
|
+
describe 'command' do
|
8
|
+
subject { command }
|
9
|
+
its(:description) { should eq "Unbind a service from an application" }
|
10
|
+
it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
|
11
|
+
end
|
12
|
+
|
13
|
+
include_examples 'inputs must have descriptions'
|
14
|
+
|
15
|
+
describe 'arguments' do
|
16
|
+
subject { command.arguments }
|
17
|
+
it 'has the correct argument order' do
|
18
|
+
should eq([
|
19
|
+
{ :type => :optional, :value => nil, :name => :service },
|
20
|
+
{ :type => :optional, :value => nil, :name => :app }
|
21
|
+
])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF::Space
|
4
|
+
class Base; def fake_method; end
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module CF
|
9
|
+
module Space
|
10
|
+
describe Base do
|
11
|
+
describe "#run" do
|
12
|
+
subject { CF::Space::Base.new }
|
13
|
+
|
14
|
+
it "uses a populator to set organization" do
|
15
|
+
organization = double
|
16
|
+
CF::Populators::Organization.should_receive(:new) { double(:populator, :populate_and_save! => organization) }
|
17
|
+
subject.run(:fake_method)
|
18
|
+
subject.org.should == organization
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".space_by_name" do
|
23
|
+
subject { CF::Space::Base.space_by_name }
|
24
|
+
let(:org) { double(:organization) }
|
25
|
+
|
26
|
+
before do
|
27
|
+
org.should_receive(:space_by_name).with("mySpace").and_return(space)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
context "with a space" do
|
32
|
+
let(:space) { double(:space) }
|
33
|
+
it "returns a space matching the name from the given org" do
|
34
|
+
CF::Space::Base.space_by_name.call("mySpace", org).should == space
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with no matching space" do
|
39
|
+
let(:space) { nil }
|
40
|
+
it "fails when no space matches the name" do
|
41
|
+
expect {
|
42
|
+
CF::Space::Base.space_by_name.call("mySpace", org)
|
43
|
+
}.to raise_exception
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|