af 0.3.22 → 0.5.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/LICENSE +1277 -24
- data/Rakefile +24 -87
- data/bin/af +7 -2
- data/lib/af/version.rb +3 -0
- data/lib/vmc.rb +7 -2
- data/lib/vmc/cli.rb +475 -0
- data/lib/vmc/cli/app/app.rb +45 -0
- data/lib/vmc/cli/app/apps.rb +105 -0
- data/lib/vmc/cli/app/base.rb +82 -0
- data/lib/vmc/cli/app/crashes.rb +46 -0
- data/lib/vmc/cli/app/delete.rb +95 -0
- data/lib/vmc/cli/app/deprecated.rb +11 -0
- data/lib/vmc/cli/app/env.rb +78 -0
- data/lib/vmc/cli/app/files.rb +137 -0
- data/lib/vmc/cli/app/health.rb +26 -0
- data/lib/vmc/cli/app/instances.rb +53 -0
- data/lib/vmc/cli/app/logs.rb +76 -0
- data/lib/vmc/cli/app/push.rb +107 -0
- data/lib/vmc/cli/app/push/create.rb +150 -0
- data/lib/vmc/cli/app/push/interactions.rb +100 -0
- data/lib/vmc/cli/app/push/sync.rb +64 -0
- data/lib/vmc/cli/app/rename.rb +39 -0
- data/lib/vmc/cli/app/restart.rb +20 -0
- data/lib/vmc/cli/app/scale.rb +71 -0
- data/lib/vmc/cli/app/start.rb +93 -0
- data/lib/vmc/cli/app/stats.rb +67 -0
- data/lib/vmc/cli/app/stop.rb +27 -0
- data/lib/vmc/cli/domain/base.rb +12 -0
- data/lib/vmc/cli/domain/domains.rb +40 -0
- data/lib/vmc/cli/domain/map.rb +55 -0
- data/lib/vmc/cli/domain/unmap.rb +56 -0
- data/lib/vmc/cli/help.rb +16 -0
- data/lib/vmc/cli/interactive.rb +105 -0
- data/lib/vmc/cli/organization/base.rb +14 -0
- data/lib/vmc/cli/organization/create.rb +32 -0
- data/lib/vmc/cli/organization/delete.rb +73 -0
- data/lib/vmc/cli/organization/org.rb +45 -0
- data/lib/vmc/cli/organization/orgs.rb +35 -0
- data/lib/vmc/cli/organization/rename.rb +36 -0
- data/lib/vmc/cli/route/base.rb +12 -0
- data/lib/vmc/cli/route/map.rb +80 -0
- data/lib/vmc/cli/route/routes.rb +26 -0
- data/lib/vmc/cli/route/unmap.rb +94 -0
- data/lib/vmc/cli/service/base.rb +8 -0
- data/lib/vmc/cli/service/bind.rb +44 -0
- data/lib/vmc/cli/service/create.rb +126 -0
- data/lib/vmc/cli/service/delete.rb +86 -0
- data/lib/vmc/cli/service/rename.rb +35 -0
- data/lib/vmc/cli/service/service.rb +42 -0
- data/lib/vmc/cli/service/services.rb +115 -0
- data/lib/vmc/cli/service/unbind.rb +38 -0
- data/lib/vmc/cli/space/base.rb +21 -0
- data/lib/vmc/cli/space/create.rb +56 -0
- data/lib/vmc/cli/space/delete.rb +95 -0
- data/lib/vmc/cli/space/rename.rb +39 -0
- data/lib/vmc/cli/space/space.rb +64 -0
- data/lib/vmc/cli/space/spaces.rb +55 -0
- data/lib/vmc/cli/space/take.rb +16 -0
- data/lib/vmc/cli/start/base.rb +80 -0
- data/lib/vmc/cli/start/colors.rb +13 -0
- data/lib/vmc/cli/start/info.rb +122 -0
- data/lib/vmc/cli/start/login.rb +92 -0
- data/lib/vmc/cli/start/logout.rb +13 -0
- data/lib/vmc/cli/start/target.rb +64 -0
- data/lib/vmc/cli/start/target_interactions.rb +37 -0
- data/lib/vmc/cli/start/targets.rb +16 -0
- data/lib/vmc/cli/user/base.rb +29 -0
- data/lib/vmc/cli/user/create.rb +39 -0
- data/lib/vmc/cli/user/delete.rb +25 -0
- data/lib/vmc/cli/user/passwd.rb +50 -0
- data/lib/vmc/cli/user/register.rb +42 -0
- data/lib/vmc/cli/user/users.rb +32 -0
- data/lib/vmc/constants.rb +13 -0
- data/lib/vmc/detect.rb +134 -0
- data/lib/vmc/errors.rb +17 -0
- data/lib/vmc/plugin.rb +56 -0
- data/lib/vmc/spacing.rb +89 -0
- data/lib/vmc/spec_helper.rb +1 -0
- data/lib/vmc/test_support.rb +4 -0
- data/lib/vmc/test_support/command_helper.rb +32 -0
- data/lib/vmc/test_support/common_input_examples.rb +14 -0
- data/lib/vmc/test_support/fake_home_dir.rb +16 -0
- data/lib/vmc/test_support/interact_helper.rb +29 -0
- data/lib/vmc/version.rb +3 -0
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/main.rb +6 -0
- data/spec/features/new_user_flow_spec.rb +71 -0
- data/spec/spec_helper.rb +63 -0
- data/spec/vmc/cli/app/base_spec.rb +17 -0
- data/spec/vmc/cli/app/delete_spec.rb +188 -0
- data/spec/vmc/cli/app/instances_spec.rb +65 -0
- data/spec/vmc/cli/app/push/create_spec.rb +571 -0
- data/spec/vmc/cli/app/push_spec.rb +369 -0
- data/spec/vmc/cli/app/rename_spec.rb +104 -0
- data/spec/vmc/cli/app/scale_spec.rb +81 -0
- data/spec/vmc/cli/app/stats_spec.rb +62 -0
- data/spec/vmc/cli/domain/map_spec.rb +140 -0
- data/spec/vmc/cli/domain/unmap_spec.rb +73 -0
- data/spec/vmc/cli/organization/orgs_spec.rb +108 -0
- data/spec/vmc/cli/organization/rename_spec.rb +113 -0
- data/spec/vmc/cli/route/map_spec.rb +138 -0
- data/spec/vmc/cli/route/unmap_spec.rb +215 -0
- data/spec/vmc/cli/service/bind_spec.rb +25 -0
- data/spec/vmc/cli/service/delete_spec.rb +22 -0
- data/spec/vmc/cli/service/rename_spec.rb +105 -0
- data/spec/vmc/cli/service/service_spec.rb +23 -0
- data/spec/vmc/cli/service/unbind_spec.rb +25 -0
- data/spec/vmc/cli/space/rename_spec.rb +102 -0
- data/spec/vmc/cli/space/spaces_spec.rb +104 -0
- data/spec/vmc/cli/start/info_spec.rb +153 -0
- data/spec/vmc/cli/start/login_spec.rb +71 -0
- data/spec/vmc/cli/user/create_spec.rb +54 -0
- data/spec/vmc/cli/user/passwd_spec.rb +102 -0
- data/spec/vmc/cli/user/register_spec.rb +148 -0
- data/spec/vmc/cli_spec.rb +448 -0
- data/spec/vmc/detect_spec.rb +54 -0
- metadata +231 -124
- data/README.md +0 -155
- data/caldecott_helper/Gemfile +0 -10
- data/caldecott_helper/Gemfile.lock +0 -48
- data/caldecott_helper/server.rb +0 -43
- data/config/clients.yml +0 -17
- data/config/micro/offline.conf +0 -2
- data/config/micro/paths.yml +0 -22
- data/config/micro/refresh_ip.rb +0 -20
- data/lib/cli.rb +0 -48
- data/lib/cli/commands/admin.rb +0 -81
- data/lib/cli/commands/apps.rb +0 -1358
- data/lib/cli/commands/base.rb +0 -233
- data/lib/cli/commands/manifest.rb +0 -56
- data/lib/cli/commands/micro.rb +0 -115
- data/lib/cli/commands/misc.rb +0 -147
- data/lib/cli/commands/services.rb +0 -217
- data/lib/cli/commands/user.rb +0 -70
- data/lib/cli/config.rb +0 -176
- data/lib/cli/console_helper.rb +0 -163
- data/lib/cli/core_ext.rb +0 -122
- data/lib/cli/errors.rb +0 -19
- data/lib/cli/file_helper.rb +0 -123
- data/lib/cli/frameworks.rb +0 -265
- data/lib/cli/manifest_helper.rb +0 -316
- data/lib/cli/runner.rb +0 -633
- data/lib/cli/services_helper.rb +0 -104
- data/lib/cli/tunnel_helper.rb +0 -336
- data/lib/cli/usage.rb +0 -129
- data/lib/cli/version.rb +0 -7
- data/lib/cli/zip_util.rb +0 -102
- data/lib/vmc/client.rb +0 -574
- data/lib/vmc/const.rb +0 -27
- data/lib/vmc/micro.rb +0 -56
- data/lib/vmc/micro/switcher/base.rb +0 -97
- data/lib/vmc/micro/switcher/darwin.rb +0 -19
- data/lib/vmc/micro/switcher/dummy.rb +0 -15
- data/lib/vmc/micro/switcher/linux.rb +0 -16
- data/lib/vmc/micro/switcher/windows.rb +0 -31
- data/lib/vmc/micro/vmrun.rb +0 -158
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VMC::Service::Bind do
|
4
|
+
describe 'metadata' do
|
5
|
+
let(:command) { Mothership.commands[:bind_service] }
|
6
|
+
|
7
|
+
describe 'command' do
|
8
|
+
subject { command }
|
9
|
+
its(:description) { should eq "Bind a service to 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,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VMC::Service::Delete do
|
4
|
+
describe 'metadata' do
|
5
|
+
let(:command) { Mothership.commands[:delete_service] }
|
6
|
+
|
7
|
+
describe 'command' do
|
8
|
+
subject { command }
|
9
|
+
its(:description) { should eq "Delete a service" }
|
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([{:type => :optional, :value => nil, :name => :service }])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "vmc/cli/service/rename"
|
3
|
+
|
4
|
+
describe VMC::Service::Rename do
|
5
|
+
let(:global) { { :color => false, :quiet => true } }
|
6
|
+
let(:inputs) { {} }
|
7
|
+
let(:given) { {} }
|
8
|
+
let(:client) { fake_client }
|
9
|
+
let(:service) {}
|
10
|
+
let(:new_name) { "some-new-name" }
|
11
|
+
|
12
|
+
before do
|
13
|
+
any_instance_of(VMC::CLI) do |cli|
|
14
|
+
stub(cli).client { client }
|
15
|
+
stub(cli).precondition { nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
subject { Mothership.new.invoke(:rename_service, inputs, given, global) }
|
20
|
+
|
21
|
+
describe 'metadata' do
|
22
|
+
let(:command) { Mothership.commands[:rename_service] }
|
23
|
+
|
24
|
+
describe 'command' do
|
25
|
+
subject { command }
|
26
|
+
its(:description) { should eq "Rename a service" }
|
27
|
+
it { expect(Mothership::Help.group(:services, :manage)).to include(subject) }
|
28
|
+
end
|
29
|
+
|
30
|
+
include_examples 'inputs must have descriptions'
|
31
|
+
|
32
|
+
describe 'arguments' do
|
33
|
+
subject { command.arguments }
|
34
|
+
it 'has the correct argument order' do
|
35
|
+
should eq([
|
36
|
+
{ :type => :optional, :value => nil, :name => :service },
|
37
|
+
{ :type => :optional, :value => nil, :name => :name }
|
38
|
+
])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when there are no services' do
|
44
|
+
context 'and a service is given' do
|
45
|
+
let(:given) { { :service => "some-service" } }
|
46
|
+
it { expect { subject }.to raise_error(VMC::UserError, "Unknown service 'some-service'.") }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'and a service is not given' do
|
50
|
+
it { expect { subject }.to raise_error(VMC::UserError, "No services.") }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when there are services' do
|
55
|
+
let(:client) { fake_client(:service_instances => services) }
|
56
|
+
let(:services) { fake_list(:service_instance, 2) }
|
57
|
+
let(:renamed_service) { services.first }
|
58
|
+
|
59
|
+
context 'when the defaults are used' do
|
60
|
+
it 'asks for the service and new name and renames' do
|
61
|
+
mock_ask("Rename which service?", anything) { renamed_service }
|
62
|
+
mock_ask("New name") { new_name }
|
63
|
+
mock(renamed_service).name=(new_name)
|
64
|
+
mock(renamed_service).update!
|
65
|
+
subject
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when no name is provided, but a service is' do
|
70
|
+
let(:given) { { :service => renamed_service.name } }
|
71
|
+
|
72
|
+
it 'asks for the new name and renames' do
|
73
|
+
dont_allow_ask("Rename which service?", anything)
|
74
|
+
mock_ask("New name") { new_name }
|
75
|
+
mock(renamed_service).name=(new_name)
|
76
|
+
mock(renamed_service).update!
|
77
|
+
subject
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when a service is provided and a name' do
|
82
|
+
let(:inputs) { { :service => renamed_service, :name => new_name } }
|
83
|
+
|
84
|
+
it 'renames the service' do
|
85
|
+
mock(renamed_service).update!
|
86
|
+
subject
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'displays the progress' do
|
90
|
+
mock_with_progress("Renaming to #{new_name}")
|
91
|
+
mock(renamed_service).update!
|
92
|
+
|
93
|
+
subject
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'and the name already exists' do
|
97
|
+
it 'fails' do
|
98
|
+
mock(renamed_service).update! { raise CFoundry::ServiceInstanceNameTaken.new("Taken", 200) }
|
99
|
+
expect { subject }.to raise_error(CFoundry::ServiceInstanceNameTaken)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VMC::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,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VMC::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,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "vmc/cli/space/rename"
|
3
|
+
|
4
|
+
describe VMC::Space::Rename do
|
5
|
+
let(:spaces) { fake_list(:space, 3) }
|
6
|
+
let(:organization) { fake(:organization, :spaces => spaces) }
|
7
|
+
let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
|
8
|
+
let(:new_name) { "some-new-name" }
|
9
|
+
|
10
|
+
before do
|
11
|
+
any_instance_of described_class do |cli|
|
12
|
+
stub(cli).client { client }
|
13
|
+
stub(cli).precondition { nil }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'metadata' do
|
18
|
+
let(:command) { Mothership.commands[:rename_space] }
|
19
|
+
|
20
|
+
describe 'command' do
|
21
|
+
subject { command }
|
22
|
+
its(:description) { should eq "Rename a space" }
|
23
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
24
|
+
end
|
25
|
+
|
26
|
+
include_examples 'inputs must have descriptions'
|
27
|
+
|
28
|
+
describe 'arguments' do
|
29
|
+
subject { command.arguments }
|
30
|
+
it 'has the correct argument order' do
|
31
|
+
should eq([
|
32
|
+
{ :type => :optional, :value => nil, :name => :space },
|
33
|
+
{ :type => :optional, :value => nil, :name => :name }
|
34
|
+
])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when there are no spaces' do
|
40
|
+
let(:spaces) { [] }
|
41
|
+
|
42
|
+
context 'and a space is given' do
|
43
|
+
subject { vmc %W[rename-space --space some-invalid-space --no-force --no-quiet] }
|
44
|
+
it 'prints out an error message' do
|
45
|
+
subject
|
46
|
+
expect(stderr.string).to include "Unknown space 'some-invalid-space'."
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'and a space is not given' do
|
51
|
+
subject { vmc %W[rename-space --no-force] }
|
52
|
+
it 'prints out an error message' do
|
53
|
+
subject
|
54
|
+
expect(stderr.string).to include "No spaces."
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'when there are spaces' do
|
60
|
+
let(:renamed_space) { spaces.first }
|
61
|
+
|
62
|
+
context 'when the defaults are used' do
|
63
|
+
subject { vmc %W[rename-space --no-force --no-quiet] }
|
64
|
+
|
65
|
+
it 'asks for the space and new name and renames' do
|
66
|
+
mock_ask("Rename which space?", anything) { renamed_space }
|
67
|
+
mock_ask("New name") { new_name }
|
68
|
+
mock(renamed_space).name=(new_name)
|
69
|
+
mock(renamed_space).update!
|
70
|
+
subject
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when no name is provided, but a space is' do
|
75
|
+
subject { vmc %W[rename-space --space #{renamed_space.name} --no-force] }
|
76
|
+
|
77
|
+
it 'asks for the new name and renames' do
|
78
|
+
dont_allow_ask("Rename which space?", anything)
|
79
|
+
mock_ask("New name") { new_name }
|
80
|
+
mock(renamed_space).name=(new_name)
|
81
|
+
mock(renamed_space).update!
|
82
|
+
subject
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when a space is provided and a name' do
|
87
|
+
subject { vmc %W[rename-space --space #{renamed_space.name} --name #{new_name} --no-force] }
|
88
|
+
|
89
|
+
it 'renames the space' do
|
90
|
+
mock(renamed_space).update!
|
91
|
+
subject
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'displays the progress' do
|
95
|
+
mock_with_progress("Renaming to #{new_name}")
|
96
|
+
mock(renamed_space).update!
|
97
|
+
|
98
|
+
subject
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
describe VMC::Space::Spaces do
|
5
|
+
let(:full) { false }
|
6
|
+
let!(:space_1) { fake(:space, :name => "bb_second", :apps => fake_list(:app, 2), :service_instances => [fake(:service_instance)]) }
|
7
|
+
let!(:space_2) { fake(:space, :name => "aa_first", :apps => [fake(:app)], :service_instances => fake_list(:service_instance, 3), :domains => [fake(:domain)]) }
|
8
|
+
let!(:space_3) { fake(:space, :name => "cc_last", :apps => fake_list(:app, 2), :service_instances => fake_list(:service_instance, 2), :domains => fake_list(:domain, 2)) }
|
9
|
+
let(:spaces) { [space_1, space_2, space_3]}
|
10
|
+
let(:organization) { fake(:organization, :spaces => spaces) }
|
11
|
+
let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
any_instance_of described_class do |cli|
|
15
|
+
stub(cli).client { client }
|
16
|
+
stub(cli).precondition { nil }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'metadata' do
|
21
|
+
let(:command) { Mothership.commands[:spaces] }
|
22
|
+
|
23
|
+
describe 'command' do
|
24
|
+
subject { command }
|
25
|
+
its(:description) { should eq "List spaces in an organization" }
|
26
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
27
|
+
end
|
28
|
+
|
29
|
+
include_examples 'inputs must have descriptions'
|
30
|
+
|
31
|
+
describe 'arguments' do
|
32
|
+
subject { command.arguments }
|
33
|
+
it 'has the correct argument order' do
|
34
|
+
should eq([{ :type => :optional, :value => nil, :name => :organization }])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
subject { vmc %W[spaces --#{bool_flag(:full)} --no-quiet] }
|
40
|
+
|
41
|
+
it 'should have the correct first two lines' do
|
42
|
+
subject
|
43
|
+
|
44
|
+
stdout.rewind
|
45
|
+
expect(stdout.readline).to match /Getting spaces.*OK/
|
46
|
+
expect(stdout.readline).to eq "\n"
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when there are no spaces' do
|
50
|
+
let(:spaces) { [] }
|
51
|
+
|
52
|
+
context 'and the full flag is given' do
|
53
|
+
let(:full) { true }
|
54
|
+
|
55
|
+
it 'displays yaml-style output with all space details' do
|
56
|
+
any_instance_of VMC::Space::Spaces do |spaces|
|
57
|
+
dont_allow(spaces).invoke
|
58
|
+
end
|
59
|
+
subject
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'and the full flag is not given (default is false)' do
|
64
|
+
it 'should show only the progress' do
|
65
|
+
subject
|
66
|
+
|
67
|
+
stdout.rewind
|
68
|
+
expect(stdout.readline).to match /Getting spaces.*OK/
|
69
|
+
expect(stdout).to be_eof
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when there are spaces' do
|
75
|
+
context 'and the full flag is given' do
|
76
|
+
let(:full) { true }
|
77
|
+
|
78
|
+
it 'displays yaml-style output with all space details' do
|
79
|
+
any_instance_of VMC::Space::Spaces do |spaces|
|
80
|
+
mock(spaces).invoke(:space, :space => space_2, :full => true).ordered
|
81
|
+
mock(spaces).invoke(:space, :space => space_1, :full => true).ordered
|
82
|
+
mock(spaces).invoke(:space, :space => space_3, :full => true).ordered
|
83
|
+
end
|
84
|
+
subject
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'and the full flag is not given (default is false)' do
|
89
|
+
it 'displays tabular output with names, spaces and domains' do
|
90
|
+
subject
|
91
|
+
|
92
|
+
stdout.rewind
|
93
|
+
stdout.readline
|
94
|
+
stdout.readline
|
95
|
+
|
96
|
+
expect(stdout.readline).to match /name\s+apps\s+services/
|
97
|
+
spaces.sort_by(&:name).each do |space|
|
98
|
+
expect(stdout.readline).to match /#{space.name}\s+#{name_list(space.apps)}\s+#{name_list(space.service_instances)}/
|
99
|
+
end
|
100
|
+
expect(stdout).to be_eof
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VMC::Start::Info do
|
4
|
+
let(:frameworks) { false }
|
5
|
+
let(:runtimes) { false }
|
6
|
+
let(:services) { false }
|
7
|
+
let(:all) { false }
|
8
|
+
|
9
|
+
let(:client) do
|
10
|
+
fake_client :frameworks => fake_list(:framework, 3),
|
11
|
+
:runtimes => fake_list(:runtime, 3),
|
12
|
+
:services => fake_list(:service, 3),
|
13
|
+
:token => CFoundry::AuthToken.new("bearer some-access-token")
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:target_info) do
|
17
|
+
{:description => "Some description",
|
18
|
+
:version => 2,
|
19
|
+
:support => "http://example.com"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
before do
|
24
|
+
any_instance_of described_class do |cli|
|
25
|
+
stub(cli).client { client }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'metadata' do
|
30
|
+
let(:command) { Mothership.commands[:info] }
|
31
|
+
|
32
|
+
describe 'command' do
|
33
|
+
subject { command }
|
34
|
+
its(:description) { should eq "Display information on the current target, user, etc." }
|
35
|
+
it { expect(Mothership::Help.group(:start)).to include(subject) }
|
36
|
+
end
|
37
|
+
|
38
|
+
include_examples 'inputs must have descriptions'
|
39
|
+
|
40
|
+
describe 'flags' do
|
41
|
+
subject { command.flags }
|
42
|
+
|
43
|
+
its(["-f"]) { should eq :frameworks }
|
44
|
+
its(["-r"]) { should eq :runtimes }
|
45
|
+
its(["-s"]) { should eq :services }
|
46
|
+
its(["-a"]) { should eq :all }
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'arguments' do
|
50
|
+
subject { command.arguments }
|
51
|
+
it { should be_empty }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
subject { vmc %W[info --#{bool_flag(:frameworks)} --#{bool_flag(:runtimes)} --#{bool_flag(:services)} --#{bool_flag(:all)} --no-force --no-quiet] }
|
57
|
+
|
58
|
+
context 'when given no flags' do
|
59
|
+
it "displays target information" do
|
60
|
+
mock(client).info { target_info }
|
61
|
+
|
62
|
+
subject
|
63
|
+
|
64
|
+
stdout.rewind
|
65
|
+
expect(stdout.readline).to eq "Some description\n"
|
66
|
+
expect(stdout.readline).to eq "\n"
|
67
|
+
expect(stdout.readline).to eq "target: #{client.target}\n"
|
68
|
+
expect(stdout.readline).to eq " version: 2\n"
|
69
|
+
expect(stdout.readline).to eq " support: http://example.com\n"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when given --frameworks' do
|
74
|
+
let(:frameworks) { true }
|
75
|
+
|
76
|
+
it 'does not grab /info' do
|
77
|
+
dont_allow(client).info
|
78
|
+
subject
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'lists frameworks on the target' do
|
82
|
+
subject
|
83
|
+
|
84
|
+
stdout.rewind
|
85
|
+
expect(stdout.readline).to match /Getting frameworks.*OK/
|
86
|
+
expect(stdout.readline).to eq "\n"
|
87
|
+
expect(stdout.readline).to match /framework\s+description/
|
88
|
+
|
89
|
+
client.frameworks.sort_by(&:name).each do |f|
|
90
|
+
expect(stdout.readline).to match /#{f.name}\s+#{f.description}/
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when given --runtimes' do
|
96
|
+
let(:runtimes) { true }
|
97
|
+
|
98
|
+
it 'does not grab /info' do
|
99
|
+
dont_allow(client).info
|
100
|
+
subject
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'lists runtimes on the target' do
|
104
|
+
subject
|
105
|
+
|
106
|
+
stdout.rewind
|
107
|
+
expect(stdout.readline).to match /Getting runtimes.*OK/
|
108
|
+
expect(stdout.readline).to eq "\n"
|
109
|
+
expect(stdout.readline).to match /runtime\s+description/
|
110
|
+
|
111
|
+
client.runtimes.sort_by(&:name).each do |r|
|
112
|
+
expect(stdout.readline).to match /#{r.name}\s+#{r.description}/
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when given --services' do
|
118
|
+
let(:services) { true }
|
119
|
+
|
120
|
+
it 'does not grab /info' do
|
121
|
+
dont_allow(client).info
|
122
|
+
subject
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'lists services on the target' do
|
126
|
+
subject
|
127
|
+
|
128
|
+
stdout.rewind
|
129
|
+
expect(stdout.readline).to match /Getting services.*OK/
|
130
|
+
expect(stdout.readline).to eq "\n"
|
131
|
+
expect(stdout.readline).to match /service\s+version\s+provider\s+plans\s+description/
|
132
|
+
|
133
|
+
client.services.sort_by(&:label).each do |s|
|
134
|
+
expect(stdout.readline).to match /#{s.label}\s+#{s.version}\s+#{s.provider}.+#{s.description}/
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'when given --all' do
|
140
|
+
let(:all) { true }
|
141
|
+
|
142
|
+
it 'combines --frameworks --runtimes and --services' do
|
143
|
+
mock(client).info { target_info }
|
144
|
+
|
145
|
+
subject
|
146
|
+
|
147
|
+
stdout.rewind
|
148
|
+
expect(stdout.readline).to match /Getting runtimes.*OK/
|
149
|
+
expect(stdout.readline).to match /Getting frameworks.*OK/
|
150
|
+
expect(stdout.readline).to match /Getting services.*OK/
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|