cf 1.1.3.rc1 → 1.1.4
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.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,271 +1,272 @@
|
|
1
|
-
require
|
2
|
-
require "cf/cli/app/push"
|
3
|
-
|
4
|
-
describe CF::App::Push do
|
5
|
-
let(:global) { { :color => false, :quiet => true } }
|
6
|
-
let(:inputs) { {} }
|
7
|
-
let(:given) { {} }
|
8
|
-
let(:path) { "somepath" }
|
9
|
-
let(:client) { fake_client }
|
10
|
-
let(:push) { CF::App::Push.new(Mothership.commands[:push]) }
|
11
|
-
|
12
|
-
before do
|
13
|
-
any_instance_of(CF::CLI) do |cli|
|
14
|
-
stub(cli).client { client }
|
15
|
-
stub(cli).precondition { nil }
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require "spec_helper"
|
18
2
|
|
19
|
-
|
20
|
-
|
3
|
+
module CF
|
4
|
+
module App
|
5
|
+
describe Push do
|
6
|
+
let(:global) { {:color => false, :quiet => true} }
|
7
|
+
let(:inputs) { {} }
|
8
|
+
let(:given) { {} }
|
9
|
+
let(:path) { "somepath" }
|
10
|
+
let(:client) { fake_client }
|
11
|
+
let(:push) { CF::App::Push.new(Mothership.commands[:push]) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
CF::CLI.any_instance.stub(:client) { client }
|
15
|
+
CF::CLI.any_instance.stub(:precondition) { nil }
|
16
|
+
end
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
its(:description) { should eq "Push an application, syncing changes if it exists" }
|
25
|
-
it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
|
26
|
-
end
|
18
|
+
describe 'metadata' do
|
19
|
+
let(:command) { Mothership.commands[:push] }
|
27
20
|
|
28
|
-
|
21
|
+
describe 'command' do
|
22
|
+
subject { command }
|
23
|
+
its(:description) { should eq "Push an application, syncing changes if it exists" }
|
24
|
+
it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
|
25
|
+
end
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
include_examples 'inputs must have descriptions'
|
28
|
+
|
29
|
+
describe 'arguments' do
|
30
|
+
subject { command.arguments }
|
31
|
+
it 'has the correct argument order' do
|
32
|
+
should eq([{:type => :optional, :value => nil, :name => :name}])
|
33
|
+
end
|
34
|
+
end
|
34
35
|
end
|
35
|
-
end
|
36
|
-
end
|
37
36
|
|
38
|
-
|
39
|
-
|
37
|
+
describe '#sync_app' do
|
38
|
+
let(:app) { fake(:app) }
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
before do
|
41
|
+
app.stub(:upload)
|
42
|
+
app.changes = {}
|
43
|
+
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
subject do
|
46
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
47
|
+
push.sync_app(app, path)
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
shared_examples 'common tests for inputs' do |*args|
|
51
|
+
context 'when the new input is the same as the old' do
|
52
|
+
type, input = args
|
53
|
+
input ||= type
|
55
54
|
|
56
|
-
|
55
|
+
let(:inputs) { {input => old} }
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
it "does not update the app's #{type}" do
|
58
|
+
push.should_not_receive(:line)
|
59
|
+
app.should_not_receive(:update!)
|
60
|
+
expect { subject }.not_to change { app.send(type) }
|
61
|
+
end
|
62
|
+
end
|
62
63
|
end
|
63
|
-
end
|
64
|
-
end
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
it "triggers the :push_app filter" do
|
66
|
+
push.should_receive(:filter).with(:push_app, app) { app }
|
67
|
+
subject
|
68
|
+
end
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
it 'uploads the app' do
|
71
|
+
app.should_receive(:upload).with(path)
|
72
|
+
subject
|
73
|
+
end
|
75
74
|
|
76
|
-
|
77
|
-
|
75
|
+
context 'when no inputs are given' do
|
76
|
+
let(:inputs) { {} }
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
it 'should not update the app' do
|
79
|
+
app.should_not_receive(:update!)
|
80
|
+
subject
|
81
|
+
end
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
83
|
+
it "should not set memory on the app" do
|
84
|
+
app.should_not_receive(:memory=)
|
85
|
+
subject
|
86
|
+
end
|
87
|
+
end
|
89
88
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
89
|
+
context 'when memory is given' do
|
90
|
+
let(:old) { 1024 }
|
91
|
+
let(:new) { "2G" }
|
92
|
+
let(:app) { fake(:app, :memory => old) }
|
93
|
+
let(:inputs) { {:memory => new} }
|
95
94
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
it 'updates the app memory, converting to megabytes' do
|
96
|
+
push.stub(:line)
|
97
|
+
app.should_receive(:update!)
|
98
|
+
expect { subject }.to change { app.memory }.from(old).to(2048)
|
99
|
+
end
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
101
|
+
it 'outputs the changed memory in human readable sizes' do
|
102
|
+
push.should_receive(:line).with("Changes:")
|
103
|
+
push.should_receive(:line).with("memory: 1G -> 2G")
|
104
|
+
app.stub(:update!)
|
105
|
+
subject
|
106
|
+
end
|
108
107
|
|
109
|
-
|
110
|
-
|
108
|
+
include_examples 'common tests for inputs', :memory
|
109
|
+
end
|
111
110
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
111
|
+
context 'when instances is given' do
|
112
|
+
let(:old) { 1 }
|
113
|
+
let(:new) { 2 }
|
114
|
+
let(:app) { fake(:app, :total_instances => old) }
|
115
|
+
let(:inputs) { {:instances => new} }
|
117
116
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
117
|
+
it 'updates the app instances' do
|
118
|
+
push.stub(:line)
|
119
|
+
app.stub(:update!)
|
120
|
+
expect { subject }.to change { app.total_instances }.from(old).to(new)
|
121
|
+
end
|
123
122
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
123
|
+
it 'outputs the changed instances' do
|
124
|
+
push.should_receive(:line).with("Changes:")
|
125
|
+
push.should_receive(:line).with("total_instances: 1 -> 2")
|
126
|
+
app.stub(:update!)
|
127
|
+
subject
|
128
|
+
end
|
130
129
|
|
131
|
-
|
132
|
-
|
130
|
+
include_examples 'common tests for inputs', :total_instances, :instances
|
131
|
+
end
|
133
132
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
133
|
+
context 'when command is given' do
|
134
|
+
let(:old) { "./start" }
|
135
|
+
let(:new) { "./start foo " }
|
136
|
+
let(:app) { fake(:app, :command => old) }
|
137
|
+
let(:inputs) { {:command => new} }
|
139
138
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
it 'updates the app command' do
|
140
|
+
push.stub(:line)
|
141
|
+
app.should_receive(:update!)
|
142
|
+
expect { subject }.to change { app.command }.from("./start").to("./start foo ")
|
143
|
+
end
|
145
144
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
145
|
+
it 'outputs the changed command in single quotes' do
|
146
|
+
push.should_receive(:line).with("Changes:")
|
147
|
+
push.should_receive(:line).with("command: './start' -> './start foo '")
|
148
|
+
app.stub(:update!)
|
149
|
+
subject
|
150
|
+
end
|
152
151
|
|
153
|
-
|
154
|
-
|
152
|
+
include_examples 'common tests for inputs', :command
|
153
|
+
end
|
155
154
|
|
156
|
-
|
157
|
-
|
155
|
+
context 'when restart is given' do
|
156
|
+
let(:inputs) { {:restart => true, :memory => 4096} }
|
158
157
|
|
159
158
|
|
160
|
-
|
161
|
-
|
159
|
+
context 'when the app is already started' do
|
160
|
+
let(:app) { fake(:app, :state => "STARTED") }
|
162
161
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
162
|
+
it 'invokes the restart command' do
|
163
|
+
push.stub(:line)
|
164
|
+
app.should_receive(:update!)
|
165
|
+
push.should_receive(:invoke).with(:restart, :app => app)
|
166
|
+
subject
|
167
|
+
end
|
169
168
|
|
170
|
-
|
171
|
-
|
169
|
+
context 'but there are no changes' do
|
170
|
+
let(:inputs) { {:restart => true} }
|
172
171
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
172
|
+
it 'invokes the restart command' do
|
173
|
+
push.stub(:line)
|
174
|
+
app.should_not_receive(:update!)
|
175
|
+
push.should_receive(:invoke).with(:restart, :app => app)
|
176
|
+
subject
|
177
|
+
end
|
178
|
+
end
|
178
179
|
end
|
179
|
-
end
|
180
|
-
end
|
181
180
|
|
182
|
-
|
183
|
-
|
181
|
+
context 'when the app is not already started' do
|
182
|
+
let(:app) { fake(:app, :state => "STOPPED") }
|
184
183
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
184
|
+
it 'does not invoke the restart command' do
|
185
|
+
push.stub(:line)
|
186
|
+
app.should_receive(:update!)
|
187
|
+
push.should_not_receive(:invoke).with(:restart, :app => app)
|
188
|
+
subject
|
189
|
+
end
|
190
|
+
end
|
190
191
|
end
|
191
|
-
end
|
192
|
-
end
|
193
192
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
193
|
+
context "when buildpack is given" do
|
194
|
+
let(:old) { nil }
|
195
|
+
let(:app) { fake(:app, :buildpack => old) }
|
196
|
+
let(:inputs) { {:buildpack => new} }
|
197
|
+
|
198
|
+
context "and it's an invalid URL" do
|
199
|
+
let(:new) { "git@github.com:foo/bar.git" }
|
200
|
+
|
201
|
+
before do
|
202
|
+
app.stub(:update!) do
|
203
|
+
raise CFoundry::MessageParseError.new(
|
204
|
+
"Request invalid due to parse error: Field: buildpack, Error: Value git@github.com:cloudfoundry/heroku-buildpack-ruby.git doesn't match regexp String /GIT_URL_REGEX/",
|
205
|
+
1001)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
it "fails and prints a pretty message" do
|
210
|
+
push.stub(:line)
|
211
|
+
expect { subject }.to raise_error(
|
212
|
+
CF::UserError, "Buildpack must be a public git repository URI.")
|
213
|
+
end
|
214
|
+
end
|
198
215
|
|
199
|
-
|
200
|
-
|
216
|
+
context "and it's a valid URL" do
|
217
|
+
let(:new) { "git://github.com/foo/bar.git" }
|
201
218
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
219
|
+
it "updates the app's buildpack" do
|
220
|
+
push.stub(:line)
|
221
|
+
app.should_receive(:update!)
|
222
|
+
expect { subject }.to change { app.buildpack }.from(old).to(new)
|
223
|
+
end
|
224
|
+
|
225
|
+
it "outputs the changed buildpack with single quotes" do
|
226
|
+
push.should_receive(:line).with("Changes:")
|
227
|
+
push.should_receive(:line).with("buildpack: '' -> '#{new}'")
|
228
|
+
app.stub(:update!)
|
229
|
+
subject
|
230
|
+
end
|
231
|
+
|
232
|
+
include_examples 'common tests for inputs', :buildpack
|
207
233
|
end
|
208
234
|
end
|
235
|
+
end
|
209
236
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
237
|
+
describe '#setup_new_app (integration spec!!)' do
|
238
|
+
let(:app) { fake(:app, :guid => nil) }
|
239
|
+
let(:host) { "" }
|
240
|
+
let(:domain) { fake(:domain, :name => "example.com") }
|
241
|
+
let(:inputs) do
|
242
|
+
{:name => "some-app",
|
243
|
+
:instances => 2,
|
244
|
+
:memory => 1024,
|
245
|
+
:host => host,
|
246
|
+
:domain => domain
|
247
|
+
}
|
214
248
|
end
|
215
|
-
|
249
|
+
let(:global) { {:quiet => true, :color => false, :force => true} }
|
216
250
|
|
217
|
-
|
218
|
-
|
251
|
+
before do
|
252
|
+
client.stub(:app) { app }
|
253
|
+
end
|
219
254
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
expect { subject }.to change { app.buildpack }.from(old).to(new)
|
255
|
+
subject do
|
256
|
+
push.input = Mothership::Inputs.new(Mothership.commands[:push], push, inputs, global, global)
|
257
|
+
push.setup_new_app(path)
|
224
258
|
end
|
225
259
|
|
226
|
-
it
|
227
|
-
|
228
|
-
|
229
|
-
|
260
|
+
it 'creates the app' do
|
261
|
+
app.should_receive(:create!)
|
262
|
+
app.should_receive(:upload).with(path)
|
263
|
+
push.should_receive(:filter).with(:create_app, app) { app }
|
264
|
+
push.should_receive(:filter).with(:push_app, app) { app }
|
265
|
+
push.should_receive(:invoke).with(:map, :app => app, :host => host, :domain => domain)
|
266
|
+
push.should_receive(:invoke).with(:start, :app => app)
|
230
267
|
subject
|
231
268
|
end
|
232
|
-
|
233
|
-
include_examples 'common tests for inputs', :buildpack
|
234
269
|
end
|
235
270
|
end
|
236
271
|
end
|
237
|
-
|
238
|
-
describe '#setup_new_app (integration spec!!)' do
|
239
|
-
let(:app) { fake(:app, :guid => nil) }
|
240
|
-
let(:host) { "" }
|
241
|
-
let(:domain) { fake(:domain, :name => "example.com") }
|
242
|
-
let(:inputs) do
|
243
|
-
{ :name => "some-app",
|
244
|
-
:instances => 2,
|
245
|
-
:memory => 1024,
|
246
|
-
:host => host,
|
247
|
-
:domain => domain
|
248
|
-
}
|
249
|
-
end
|
250
|
-
let(:global) { {:quiet => true, :color => false, :force => true} }
|
251
|
-
|
252
|
-
before do
|
253
|
-
stub(client).app { app }
|
254
|
-
end
|
255
|
-
|
256
|
-
subject do
|
257
|
-
push.input = Mothership::Inputs.new(Mothership.commands[:push], push, inputs, global, global)
|
258
|
-
push.setup_new_app(path)
|
259
|
-
end
|
260
|
-
|
261
|
-
it 'creates the app' do
|
262
|
-
mock(app).create!
|
263
|
-
mock(app).upload(path)
|
264
|
-
mock(push).filter(:create_app, app) { app }
|
265
|
-
mock(push).filter(:push_app, app) { app }
|
266
|
-
mock(push).invoke :map, :app => app, :host => host, :domain => domain
|
267
|
-
mock(push).invoke :start, :app => app
|
268
|
-
subject
|
269
|
-
end
|
270
|
-
end
|
271
272
|
end
|