cf 1.1.3.rc1 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cf/cli.rb +2 -7
- data/lib/cf/cli/organization/delete.rb +4 -6
- data/lib/cf/cli/service/create.rb +23 -17
- data/lib/cf/cli/space/create.rb +43 -41
- data/lib/cf/cli/space/space.rb +49 -46
- data/lib/cf/version.rb +1 -1
- data/lib/console/console.rb +1 -1
- data/spec/cf/cli/app/delete_spec.rb +16 -28
- data/spec/cf/cli/app/instances_spec.rb +4 -5
- data/spec/cf/cli/app/push/create_spec.rb +362 -373
- data/spec/cf/cli/app/push_spec.rb +216 -215
- data/spec/cf/cli/app/rename_spec.rb +28 -31
- data/spec/cf/cli/app/scale_spec.rb +44 -41
- data/spec/cf/cli/app/start_spec.rb +194 -193
- data/spec/cf/cli/app/stats_spec.rb +55 -56
- data/spec/cf/cli/domain/map_spec.rb +105 -102
- data/spec/cf/cli/domain/unmap_spec.rb +60 -56
- data/spec/cf/cli/organization/delete_spec.rb +85 -84
- data/spec/cf/cli/organization/orgs_spec.rb +80 -83
- data/spec/cf/cli/organization/rename_spec.rb +90 -89
- data/spec/cf/cli/populators/organization_spec.rb +117 -119
- data/spec/cf/cli/populators/space_spec.rb +107 -108
- data/spec/cf/cli/populators/target_spec.rb +17 -12
- data/spec/cf/cli/route/delete_spec.rb +4 -4
- data/spec/cf/cli/route/map_spec.rb +106 -102
- data/spec/cf/cli/route/unmap_spec.rb +5 -5
- data/spec/cf/cli/service/create_spec.rb +74 -46
- data/spec/cf/cli/service/rename_spec.rb +29 -33
- data/spec/cf/cli/service/services_spec.rb +48 -48
- data/spec/cf/cli/space/base_spec.rb +39 -32
- data/spec/cf/cli/space/create_spec.rb +52 -53
- data/spec/cf/cli/space/delete_spec.rb +84 -85
- data/spec/cf/cli/space/rename_spec.rb +93 -94
- data/spec/cf/cli/space/space_spec.rb +60 -60
- data/spec/cf/cli/space/spaces_spec.rb +75 -80
- data/spec/cf/cli/space/switch_space_spec.rb +45 -48
- data/spec/cf/cli/start/info_spec.rb +4 -6
- data/spec/cf/cli/start/login_spec.rb +18 -20
- data/spec/cf/cli/start/logout_spec.rb +36 -37
- data/spec/cf/cli/start/target_spec.rb +86 -89
- data/spec/cf/cli/user/create_spec.rb +83 -84
- data/spec/cf/cli/user/passwd_spec.rb +87 -86
- data/spec/cf/cli/user/register_spec.rb +109 -108
- data/spec/cf/cli_spec.rb +305 -310
- data/spec/console/console_spec.rb +58 -58
- data/spec/factories/cfoundry/v2/domain_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/route_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/user_factory.rb +7 -0
- data/spec/features/org_spec.rb +11 -11
- data/spec/manifests/manifests_spec.rb +21 -21
- data/spec/manifests/plugin_spec.rb +34 -34
- data/spec/spec_helper.rb +1 -2
- data/spec/support/cli_helper.rb +5 -14
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/interact_helper.rb +5 -15
- data/spec/support/shared_examples/errors.rb +1 -1
- data/spec/tunnel/plugin_spec.rb +2 -2
- data/spec/tunnel/tunnel_spec.rb +5 -5
- metadata +36 -28
@@ -1,108 +1,107 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
include_examples 'inputs must have descriptions'
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "running the command" do
|
18
|
-
let(:space) { fake :space, :name => "some_space_name" }
|
19
|
-
let(:organization) { fake(:organization, :spaces => [space], :name => "MyOrg") }
|
20
|
-
let(:client) { fake_client(:current_organization => organization, :spaces => [space]) }
|
21
|
-
|
22
|
-
subject { capture_output { cf %W[delete-space some_space_name --quiet --force] } }
|
23
|
-
|
24
|
-
before do
|
25
|
-
any_instance_of described_class do |cli|
|
26
|
-
stub(cli).client { client }
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module Space
|
5
|
+
describe Delete do
|
6
|
+
describe "metadata" do
|
7
|
+
let(:command) { Mothership.commands[:delete_space] }
|
8
|
+
|
9
|
+
describe "command" do
|
10
|
+
subject { command }
|
11
|
+
its(:description) { should eq "Delete a space and its contents" }
|
12
|
+
it { expect(Mothership::Help.group(:spaces)).to include(subject) }
|
13
|
+
end
|
27
14
|
|
28
|
-
|
29
|
-
stub(cli).check_target
|
30
|
-
any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
|
15
|
+
include_examples "inputs must have descriptions"
|
31
16
|
end
|
32
|
-
stub(space).delete!
|
33
|
-
end
|
34
17
|
|
18
|
+
describe "running the command" do
|
19
|
+
let(:space) { fake :space, :name => "some_space_name" }
|
20
|
+
let(:organization) { fake(:organization, :spaces => [space], :name => "MyOrg") }
|
21
|
+
let(:client) { fake_client(:current_organization => organization, :spaces => [space]) }
|
35
22
|
|
36
|
-
|
37
|
-
subject { cf %W[delete-space some_space_name --quiet] }
|
38
|
-
context "when the user responds 'y'" do
|
39
|
-
it "deletes the space, exits cleanly" do
|
40
|
-
mock(space).delete!
|
41
|
-
mock_ask("Really delete #{space.name}?", {:default => false}) { true }
|
23
|
+
subject { capture_output { cf %W[delete-space some_space_name --quiet --force] } }
|
42
24
|
|
43
|
-
|
44
|
-
|
25
|
+
before do
|
26
|
+
described_class.any_instance.stub(:client) { client }
|
27
|
+
described_class.any_instance.stub(:precondition)
|
28
|
+
CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
|
29
|
+
space.stub(:delete!)
|
45
30
|
end
|
46
|
-
end
|
47
31
|
|
48
|
-
context "when the user responds 'n'" do
|
49
|
-
it "exits cleanly without deleting the space" do
|
50
|
-
dont_allow(space).delete!
|
51
|
-
mock_ask("Really delete #{space.name}?", {:default => false}) { false }
|
52
32
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
33
|
+
context "without the force parameter when prompting" do
|
34
|
+
subject { cf %W[delete-space some_space_name --quiet] }
|
35
|
+
context "when the user responds 'y'" do
|
36
|
+
it "deletes the space, exits cleanly" do
|
37
|
+
space.should_receive(:delete!)
|
38
|
+
mock_ask("Really delete #{space.name}?", {:default => false}) { true }
|
58
39
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
40
|
+
subject
|
41
|
+
@status.should == 0
|
42
|
+
end
|
43
|
+
end
|
63
44
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
45
|
+
context "when the user responds 'n'" do
|
46
|
+
it "exits cleanly without deleting the space" do
|
47
|
+
space.should_not_receive(:delete!)
|
48
|
+
mock_ask("Really delete #{space.name}?", {:default => false}) { false }
|
68
49
|
|
69
|
-
|
70
|
-
|
71
|
-
|
50
|
+
subject
|
51
|
+
@status.should == 0
|
52
|
+
end
|
53
|
+
end
|
72
54
|
end
|
73
55
|
|
74
|
-
|
75
|
-
|
76
|
-
|
56
|
+
context "when deleting the current space" do
|
57
|
+
before do
|
58
|
+
client.stub(:current_space) { space }
|
59
|
+
end
|
60
|
+
|
61
|
+
it "warns the user what they've done" do
|
62
|
+
subject
|
63
|
+
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.")
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when the current space has dependent objects" do
|
67
|
+
before do
|
68
|
+
space.stub(:delete!) { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
|
69
|
+
end
|
70
|
+
|
71
|
+
it "does not print a success message" do
|
72
|
+
subject
|
73
|
+
expect(output).to_not say("The space that you were targeting has now been deleted")
|
74
|
+
end
|
75
|
+
end
|
77
76
|
end
|
78
|
-
end
|
79
|
-
end
|
80
77
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
78
|
+
context "when a space fails to delete" do
|
79
|
+
before do
|
80
|
+
space.stub(:delete!) { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
|
81
|
+
subject
|
82
|
+
end
|
86
83
|
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
it "shows the error message" do
|
85
|
+
expect(output).to say "We don't delete children."
|
86
|
+
end
|
90
87
|
|
91
|
-
|
92
|
-
|
93
|
-
|
88
|
+
it "informs the user of how to recursively delete" do
|
89
|
+
expect(output).to say "If you want to delete the space along with all dependent objects, rerun the command with the '--recursive' flag."
|
90
|
+
end
|
94
91
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
it "returns a non-zero exit code" do
|
93
|
+
@status.should_not == 0
|
94
|
+
end
|
95
|
+
end
|
99
96
|
|
100
|
-
|
101
|
-
|
97
|
+
context "when deleting with --recursive" do
|
98
|
+
subject { cf %W[delete-space some_space_name --recursive --force] }
|
102
99
|
|
103
|
-
|
104
|
-
|
105
|
-
|
100
|
+
it "sends recursive true in its delete request" do
|
101
|
+
space.should_receive(:delete!).with(:recursive => true)
|
102
|
+
subject
|
103
|
+
end
|
104
|
+
end
|
106
105
|
end
|
107
106
|
end
|
108
107
|
end
|
@@ -1,103 +1,102 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
stub(cli).check_target
|
16
|
-
any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'metadata' do
|
21
|
-
let(:command) { Mothership.commands[:rename_space] }
|
22
|
-
|
23
|
-
describe 'command' do
|
24
|
-
subject { command }
|
25
|
-
its(:description) { should eq "Rename a space" }
|
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([
|
35
|
-
{:type => :optional, :value => nil, :name => :space},
|
36
|
-
{:type => :optional, :value => nil, :name => :name}
|
37
|
-
])
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when there are no spaces' do
|
43
|
-
let(:spaces) { [] }
|
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'."
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module Space
|
5
|
+
describe Rename do
|
6
|
+
let(:spaces) { fake_list(:space, 3) }
|
7
|
+
let(:organization) { fake(:organization, :spaces => spaces) }
|
8
|
+
let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
|
9
|
+
let(:new_name) { "some-new-name" }
|
10
|
+
|
11
|
+
before do
|
12
|
+
described_class.any_instance.stub(:client) { client }
|
13
|
+
described_class.any_instance.stub(:precondition)
|
14
|
+
CF::Populators::Organization.any_instance.stub(:populate_and_save!).and_return(organization)
|
50
15
|
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
|
-
context 'when the defaults are used' do
|
67
|
-
it 'asks for the space and new name and renames' do
|
68
|
-
mock_ask("Rename which space?", anything) { renamed_space }
|
69
|
-
mock_ask("New name") { new_name }
|
70
|
-
mock(renamed_space).name=(new_name)
|
71
|
-
mock(renamed_space).update!
|
72
|
-
subject
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'when no name is provided, but a space is' do
|
77
|
-
subject { cf %W[rename-space --space #{renamed_space.name} --no-force] }
|
78
16
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
85
37
|
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'when a space is provided and a name' do
|
89
|
-
subject { cf %W[rename-space --space #{renamed_space.name} --name #{new_name} --no-force] }
|
90
38
|
|
91
|
-
|
92
|
-
|
93
|
-
|
39
|
+
context "when there are no spaces" do
|
40
|
+
let(:spaces) { [] }
|
41
|
+
|
42
|
+
context "and a space is given" do
|
43
|
+
subject { cf %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 { cf %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
|
94
57
|
end
|
95
58
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
59
|
+
context "when there are spaces" do
|
60
|
+
let(:renamed_space) { spaces.first }
|
61
|
+
subject { cf %W[rename-space --no-force --no-quiet] }
|
62
|
+
|
63
|
+
context "when the defaults are used" do
|
64
|
+
it "asks for the space and new name and renames" do
|
65
|
+
mock_ask("Rename which space?", anything) { renamed_space }
|
66
|
+
mock_ask("New name") { new_name }
|
67
|
+
renamed_space.should_receive(:name=).with(new_name)
|
68
|
+
renamed_space.should_receive(:update!)
|
69
|
+
subject
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "when no name is provided, but a space is" do
|
74
|
+
subject { cf %W[rename-space --space #{renamed_space.name} --no-force] }
|
75
|
+
|
76
|
+
it "asks for the new name and renames" do
|
77
|
+
dont_allow_ask("Rename which space?", anything)
|
78
|
+
mock_ask("New name") { new_name }
|
79
|
+
renamed_space.should_receive(:name=).with(new_name)
|
80
|
+
renamed_space.should_receive(:update!)
|
81
|
+
subject
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when a space is provided and a name" do
|
86
|
+
subject { cf %W[rename-space --space #{renamed_space.name} --name #{new_name} --no-force] }
|
87
|
+
|
88
|
+
it "renames the space" do
|
89
|
+
renamed_space.should_receive(:update!)
|
90
|
+
subject
|
91
|
+
end
|
92
|
+
|
93
|
+
it "displays the progress" do
|
94
|
+
mock_with_progress("Renaming to #{new_name}")
|
95
|
+
renamed_space.should_receive(:update!)
|
96
|
+
|
97
|
+
subject
|
98
|
+
end
|
99
|
+
end
|
101
100
|
end
|
102
101
|
end
|
103
102
|
end
|
@@ -1,79 +1,79 @@
|
|
1
|
-
require
|
2
|
-
require 'stringio'
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module CF
|
4
|
+
module Space
|
5
|
+
describe Space do
|
6
|
+
describe "metadata" do
|
7
|
+
let(:command) { Mothership.commands[:space] }
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
13
14
|
|
14
|
-
|
15
|
+
include_examples "inputs must have descriptions"
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
22
25
|
end
|
23
|
-
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
describe "running the command" do
|
28
|
+
let(:apps) { fake_list(:app, 2) }
|
29
|
+
let(:domains) { fake_list(:domain, 2) }
|
30
|
+
let(:services) { fake_list(:service_instance, 2) }
|
31
|
+
let!(:space_1) { fake(:space, :name => "some_space_name", :apps => apps, :service_instances => services, :domains => domains) }
|
32
|
+
let(:spaces) { [space_1] }
|
33
|
+
let(:organization) { fake(:organization, :name => "Spacey Org", :spaces => spaces) }
|
34
|
+
let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
any_instance_of(CF::Populators::Space, :populate_and_save! => space_1)
|
42
|
-
end
|
43
|
-
end
|
36
|
+
before do
|
37
|
+
CF::Space::Base.any_instance.stub(:client) { client }
|
38
|
+
CF::Space::Base.any_instance.stub(: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_1)
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
43
|
+
context "with --quiet" do
|
44
|
+
subject { cf %W[space some_space_name --quiet] }
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
it "shows only the name" do
|
47
|
+
subject
|
48
|
+
expect(stdout.read).to eq("some_space_name\n")
|
49
|
+
end
|
50
|
+
end
|
53
51
|
|
54
|
-
|
55
|
-
|
52
|
+
context "with --no-quiet" do
|
53
|
+
subject { cf %W[space some_space_name --no-quiet] }
|
56
54
|
|
57
|
-
|
55
|
+
before { subject }
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
it "shows the space's name" do
|
58
|
+
expect(stdout.read).to include("some_space_name:")
|
59
|
+
end
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
it "shows the space's org" do
|
62
|
+
expect(stdout.read).to include("organization: Spacey Org")
|
63
|
+
end
|
66
64
|
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
it "shows apps" do
|
66
|
+
expect(stdout.read).to include("apps: #{apps.first.name}, #{apps.last.name}")
|
67
|
+
end
|
70
68
|
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
it "shows services" do
|
70
|
+
expect(stdout.read).to include("services: #{services.first.name}, #{services.last.name}")
|
71
|
+
end
|
74
72
|
|
75
|
-
|
76
|
-
|
73
|
+
it "shows domains" do
|
74
|
+
expect(stdout.read).to include("domains: #{domains.first.name}, #{domains.last.name}")
|
75
|
+
end
|
76
|
+
end
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|