cf 1.1.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cf/cli/start/login.rb +3 -0
- data/lib/cf/version.rb +1 -1
- data/spec/cf/cli/app/base_spec.rb +2 -2
- data/spec/cf/cli/app/delete_spec.rb +150 -129
- data/spec/cf/cli/app/instances_spec.rb +56 -51
- data/spec/cf/cli/app/push/create_spec.rb +72 -70
- data/spec/cf/cli/app/push_spec.rb +46 -43
- data/spec/cf/cli/app/rename_spec.rb +13 -6
- data/spec/cf/cli/app/scale_spec.rb +9 -4
- data/spec/cf/cli/app/start_spec.rb +28 -23
- data/spec/cf/cli/app/stats_spec.rb +9 -10
- data/spec/cf/cli/domain/map_spec.rb +13 -10
- data/spec/cf/cli/domain/unmap_spec.rb +11 -11
- data/spec/cf/cli/organization/delete_spec.rb +10 -4
- data/spec/cf/cli/organization/orgs_spec.rb +15 -4
- data/spec/cf/cli/organization/rename_spec.rb +7 -5
- data/spec/cf/cli/populators/organization_spec.rb +40 -29
- data/spec/cf/cli/populators/space_spec.rb +51 -40
- data/spec/cf/cli/populators/target_spec.rb +4 -2
- data/spec/cf/cli/route/delete_spec.rb +6 -4
- data/spec/cf/cli/route/map_spec.rb +54 -35
- data/spec/cf/cli/route/unmap_spec.rb +21 -15
- data/spec/cf/cli/service/create_spec.rb +17 -12
- data/spec/cf/cli/service/rename_spec.rb +8 -6
- data/spec/cf/cli/service/services_spec.rb +15 -8
- data/spec/cf/cli/space/create_spec.rb +5 -9
- data/spec/cf/cli/space/delete_spec.rb +9 -8
- data/spec/cf/cli/space/rename_spec.rb +15 -8
- data/spec/cf/cli/space/space_spec.rb +10 -10
- data/spec/cf/cli/space/spaces_spec.rb +11 -5
- data/spec/cf/cli/space/switch_space_spec.rb +7 -7
- data/spec/cf/cli/start/info_spec.rb +3 -1
- data/spec/cf/cli/start/login_spec.rb +1 -1
- data/spec/cf/cli/start/logout_spec.rb +1 -1
- data/spec/cf/cli/start/target_spec.rb +7 -6
- data/spec/cf/cli/user/create_spec.rb +3 -4
- data/spec/cf/cli/user/passwd_spec.rb +2 -4
- data/spec/cf/cli/user/register_spec.rb +4 -4
- data/spec/cf/cli_spec.rb +1 -3
- data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/clients_factory.rb +4 -0
- data/spec/factories/cfoundry/v2/{domain_factory.rb → domains_factory.rb} +0 -0
- data/spec/factories/cfoundry/v2/organizations_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/{route_factory.rb → routes_factory.rb} +0 -0
- data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_instances_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/service_plans_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/spaces_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/{user_factory.rb → users_factory.rb} +0 -0
- data/spec/features/push_flow_spec.rb +8 -8
- data/spec/manifests/manifests_spec.rb +34 -51
- data/spec/manifests/plugin_spec.rb +17 -6
- data/spec/spec_helper.rb +0 -1
- data/spec/support/interact_helper.rb +1 -1
- data/spec/tunnel/tunnel_spec.rb +5 -5
- metadata +37 -13
data/lib/cf/cli/start/login.rb
CHANGED
data/lib/cf/version.rb
CHANGED
@@ -1,174 +1,195 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
require "cf/cli/app/delete"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
module CF
|
5
|
+
module App
|
6
|
+
describe Delete do
|
7
|
+
let(:global) { {:color => false, :quiet => true} }
|
8
|
+
let(:inputs) { {} }
|
9
|
+
let(:given) { {} }
|
10
|
+
let(:client) { build(:client) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
CF::CLI.any_instance.stub(:client).and_return(client)
|
14
|
+
CF::CLI.any_instance.stub(:precondition).and_return(nil)
|
15
|
+
end
|
16
16
|
|
17
|
-
|
17
|
+
subject { Mothership.new.invoke(:delete, inputs, given, global) }
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
describe "metadata" do
|
20
|
+
let(:command) { Mothership.commands[:delete] }
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
describe "command" do
|
23
|
+
subject { command }
|
24
|
+
its(:description) { should eq "Delete an application" }
|
25
|
+
it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
|
26
|
+
end
|
27
27
|
|
28
|
-
|
28
|
+
include_examples "inputs must have descriptions"
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
describe "arguments" do
|
31
|
+
subject { command.arguments }
|
32
|
+
it "has the correct argument order" do
|
33
|
+
should eq([{:type => :splat, :value => nil, :name => :apps}])
|
34
|
+
end
|
35
|
+
end
|
34
36
|
end
|
35
|
-
end
|
36
|
-
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
38
|
+
context "when there are no apps" do
|
39
|
+
before do
|
40
|
+
client.stub(:apps).and_return([])
|
41
|
+
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
43
|
+
context "and an app is given" do
|
44
|
+
let(:given) { {:app => "some-app"} }
|
48
45
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
let(:app_with_orphans) {
|
56
|
-
fake :app,
|
57
|
-
:name => "app_with_orphans",
|
58
|
-
:service_bindings => [
|
59
|
-
fake(:service_binding, :service_instance => service_1),
|
60
|
-
fake(:service_binding, :service_instance => service_2)
|
61
|
-
]
|
62
|
-
}
|
63
|
-
let(:app_without_orphans) {
|
64
|
-
fake :app,
|
65
|
-
:name => "app_without_orphans",
|
66
|
-
:service_bindings => [
|
67
|
-
fake(:service_binding, :service_instance => service_1)
|
68
|
-
]
|
69
|
-
}
|
70
|
-
|
71
|
-
context 'and no app is given' do
|
72
|
-
it 'asks for the app' do
|
73
|
-
mock_ask("Delete which application?", anything) { basic_app }
|
74
|
-
stub_ask { true }
|
75
|
-
basic_app.stub(:delete!)
|
76
|
-
subject
|
46
|
+
it { expect { subject }.to raise_error(CF::UserError, "Unknown app 'some-app'.") }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "and an app is not given" do
|
50
|
+
it { expect { subject }.to raise_error(CF::UserError, "No applications.") }
|
51
|
+
end
|
77
52
|
end
|
78
|
-
end
|
79
53
|
|
80
|
-
|
81
|
-
|
82
|
-
|
54
|
+
context "when there are apps" do
|
55
|
+
let(:service_1) { build(:service_instance, :name => "service-instance-name-1") }
|
56
|
+
let(:service_2) { build(:service_instance, :name => "service-instance-name-2") }
|
57
|
+
|
58
|
+
let(:service_binding_1) { build(:service_binding, :service_instance => service_1) }
|
59
|
+
let(:service_binding_2) { build(:service_binding, :service_instance => service_2) }
|
60
|
+
|
61
|
+
let(:basic_app) { build(:app, :name => "basic-app-name", :guid => "basic-app-guid-1") }
|
62
|
+
|
63
|
+
let(:app_with_orphans) {
|
64
|
+
build(:app,
|
65
|
+
:name => "app_with_orphans",
|
66
|
+
:service_bindings => [service_binding_1, service_binding_2]
|
67
|
+
)
|
68
|
+
}
|
69
|
+
let(:app_without_orphans) {
|
70
|
+
build(:app,
|
71
|
+
:name => "app_without_orphans",
|
72
|
+
:service_bindings => [service_binding_1]
|
73
|
+
)
|
74
|
+
}
|
75
|
+
|
76
|
+
let(:apps) { [basic_app, app_with_orphans, app_without_orphans] }
|
77
|
+
|
78
|
+
before do
|
79
|
+
basic_app.stub(:service_bindings).and_return([])
|
80
|
+
client.stub(:apps).and_return(apps)
|
81
|
+
end
|
82
|
+
|
83
|
+
context "and no app is given" do
|
84
|
+
it "asks for the app" do
|
85
|
+
basic_app.stub(:delete!)
|
86
|
+
|
87
|
+
should_ask("Delete which application?", anything) { basic_app }
|
88
|
+
stub_ask { true }
|
83
89
|
|
84
|
-
context 'and it asks for confirmation' do
|
85
|
-
context 'and the user answers no' do
|
86
|
-
it 'does not delete the application' do
|
87
|
-
mock_ask("Really delete #{deleted_app.name}?", anything) { false }
|
88
|
-
deleted_app.should_not_receive(:delete!)
|
89
90
|
subject
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
|
-
context
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
context "and a basic app is given" do
|
95
|
+
let(:deleted_app) { basic_app }
|
96
|
+
let(:given) { {:app => deleted_app.name} }
|
97
|
+
|
98
|
+
context "and it asks for confirmation" do
|
99
|
+
context "and the user answers no" do
|
100
|
+
it "does not delete the application" do
|
101
|
+
should_ask("Really delete #{deleted_app.name}?", anything) { false }
|
102
|
+
deleted_app.should_not_receive(:delete!)
|
103
|
+
subject
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "and the user answers yes" do
|
108
|
+
it "deletes the application" do
|
109
|
+
should_ask("Really delete #{deleted_app.name}?", anything) { true }
|
110
|
+
deleted_app.should_receive(:delete!)
|
111
|
+
subject
|
112
|
+
end
|
113
|
+
end
|
98
114
|
end
|
99
|
-
end
|
100
|
-
end
|
101
115
|
|
102
|
-
|
103
|
-
|
116
|
+
context "and --force is given" do
|
117
|
+
let(:global) { {:force => true, :color => false, :quiet => true} }
|
104
118
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
119
|
+
it "deletes the application without asking to confirm" do
|
120
|
+
dont_allow_ask
|
121
|
+
deleted_app.should_receive(:delete!)
|
122
|
+
subject
|
123
|
+
end
|
124
|
+
end
|
109
125
|
end
|
110
|
-
end
|
111
|
-
end
|
112
126
|
|
113
|
-
|
114
|
-
|
115
|
-
|
127
|
+
context "and an app with orphaned services is given" do
|
128
|
+
let(:deleted_app) { app_with_orphans }
|
129
|
+
let(:inputs) { {:app => deleted_app} }
|
116
130
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
deleted_app.stub(:delete!)
|
131
|
+
before do
|
132
|
+
app_with_orphans.stub(:service_bindings).and_return([service_binding_1, service_binding_2])
|
133
|
+
app_with_orphans.stub(:service_instances).and_return([service_1, service_2])
|
134
|
+
end
|
122
135
|
|
123
|
-
|
136
|
+
context "and it asks for confirmation" do
|
137
|
+
context "and the user answers yes" do
|
138
|
+
it "asks to delete orphaned services" do
|
139
|
+
stub_ask("Really delete #{deleted_app.name}?", anything) { true }
|
140
|
+
deleted_app.stub(:delete!)
|
124
141
|
|
125
|
-
|
142
|
+
service_2.stub(:invalidate!)
|
126
143
|
|
127
|
-
|
144
|
+
should_ask("Delete orphaned service #{service_2.name}?", anything) { true }
|
128
145
|
|
129
|
-
|
130
|
-
end
|
131
|
-
end
|
146
|
+
CF::App::Delete.any_instance.should_receive(:invoke).with(:delete_service, :service => service_2, :really => true)
|
132
147
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
deleted_app.should_not_receive(:delete!)
|
148
|
+
subject
|
149
|
+
end
|
150
|
+
end
|
137
151
|
|
138
|
-
|
152
|
+
context "and the user answers no" do
|
153
|
+
it "does not ask to delete orphaned serivces, or delete them" do
|
154
|
+
stub_ask("Really delete #{deleted_app.name}?", anything) { false }
|
155
|
+
deleted_app.should_not_receive(:delete!)
|
139
156
|
|
140
|
-
|
157
|
+
service_2.stub(:invalidate!)
|
141
158
|
|
142
|
-
|
159
|
+
dont_allow_ask("Delete orphaned service #{service_2.name}?")
|
143
160
|
|
144
|
-
|
161
|
+
CF::App::Delete.any_instance.should_not_receive(:invoke).with(:delete_service, anything)
|
162
|
+
|
163
|
+
subject
|
164
|
+
end
|
165
|
+
end
|
145
166
|
end
|
146
|
-
end
|
147
|
-
end
|
148
167
|
|
149
|
-
|
150
|
-
|
168
|
+
context "and --force is given" do
|
169
|
+
let(:global) { {:force => true, :color => false, :quiet => true} }
|
151
170
|
|
152
|
-
|
153
|
-
|
154
|
-
|
171
|
+
it "does not delete orphaned services" do
|
172
|
+
dont_allow_ask
|
173
|
+
deleted_app.stub(:delete!)
|
155
174
|
|
156
|
-
|
175
|
+
CF::App::Delete.any_instance.should_not_receive(:invoke).with(:delete_service, anything)
|
157
176
|
|
158
|
-
|
159
|
-
|
160
|
-
|
177
|
+
subject
|
178
|
+
end
|
179
|
+
end
|
161
180
|
|
162
|
-
|
163
|
-
|
181
|
+
context "and --delete-orphaned is given" do
|
182
|
+
let(:inputs) { {:app => deleted_app, :delete_orphaned => true} }
|
164
183
|
|
165
|
-
|
166
|
-
|
167
|
-
|
184
|
+
it "deletes the orphaned services" do
|
185
|
+
stub_ask("Really delete #{deleted_app.name}?", anything) { true }
|
186
|
+
deleted_app.stub(:delete!)
|
168
187
|
|
169
|
-
|
188
|
+
CF::App::Delete.any_instance.should_receive(:invoke).with(:delete_service, :service => service_2, :really => true)
|
170
189
|
|
171
|
-
|
190
|
+
subject
|
191
|
+
end
|
192
|
+
end
|
172
193
|
end
|
173
194
|
end
|
174
195
|
end
|
@@ -1,64 +1,69 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "stringio"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
module CF
|
5
|
+
module App
|
6
|
+
describe Stats do
|
7
|
+
let(:global) { {:color => false} }
|
8
|
+
let(:inputs) { {:app => apps[0]} }
|
9
|
+
let(:given) { {} }
|
10
|
+
let(:client) { build(:client) }
|
11
|
+
let(:apps) { [build(:app, :client => client, :name => "basic-app-name")] }
|
12
|
+
let(:time) { Time.local(2012, 11, 1, 2, 30) }
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
before do
|
15
|
+
client.stub(:apps).and_return(apps)
|
16
|
+
CF::CLI.any_instance.stub(:client).and_return(client)
|
17
|
+
CF::CLI.any_instance.stub(:precondition).and_return(nil)
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
client.base.stub(:instances).with(anything) do
|
20
|
+
{
|
21
|
+
"12" => {:state => "STOPPED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"},
|
22
|
+
"1" => {:state => "STOPPED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"},
|
23
|
+
"2" => {:state => "STARTED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
subject do
|
29
|
+
capture_output do
|
30
|
+
Mothership.new.invoke(:instances, inputs, given, global)
|
31
|
+
end
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
describe "metadata" do
|
35
|
+
let(:command) { Mothership.commands[:instances] }
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
describe "command" do
|
38
|
+
subject { command }
|
39
|
+
its(:description) { should eq "List an app's instances" }
|
40
|
+
it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
|
41
|
+
end
|
39
42
|
|
40
|
-
|
43
|
+
include_examples "inputs must have descriptions"
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
describe "arguments" do
|
46
|
+
subject { command.arguments }
|
47
|
+
it "has no arguments" do
|
48
|
+
should eq([{:type => :splat, :value => nil, :name => :apps}])
|
49
|
+
end
|
50
|
+
end
|
46
51
|
end
|
47
|
-
end
|
48
|
-
end
|
49
52
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
it "prints out the instances in the correct order" do
|
54
|
+
subject
|
55
|
+
expect(output).to say("instance #1")
|
56
|
+
expect(output).to say("instance #2")
|
57
|
+
expect(output).to say("instance #12")
|
58
|
+
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
it "prints out one of the instances correctly" do
|
61
|
+
subject
|
62
|
+
expect(output).to say("instance #2: started")
|
63
|
+
expect(output).to say(" started: #{time.strftime("%F %r")}")
|
64
|
+
expect(output).to say(" debugger: port bar at foo")
|
65
|
+
expect(output).to say(" console: port qux at baz")
|
66
|
+
end
|
67
|
+
end
|
63
68
|
end
|
64
69
|
end
|