test-kitchen 1.4.2 → 1.5.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +27 -2
- data/CHANGELOG.md +40 -1
- data/Gemfile.proxy_tests +6 -0
- data/features/kitchen_driver_discover_command.feature +6 -0
- data/features/kitchen_init_command.feature +5 -3
- data/features/step_definitions/gem_steps.rb +12 -4
- data/features/step_definitions/git_steps.rb +1 -1
- data/features/step_definitions/output_steps.rb +1 -1
- data/features/support/env.rb +13 -9
- data/lib/kitchen/cli.rb +3 -0
- data/lib/kitchen/command/driver_discover.rb +8 -0
- data/lib/kitchen/configurable.rb +32 -0
- data/lib/kitchen/driver/ssh_base.rb +18 -4
- data/lib/kitchen/generator/driver_create.rb +2 -2
- data/lib/kitchen/lazy_hash.rb +20 -0
- data/lib/kitchen/provisioner/base.rb +16 -1
- data/lib/kitchen/provisioner/chef_base.rb +42 -98
- data/lib/kitchen/provisioner/chef_solo.rb +6 -4
- data/lib/kitchen/provisioner/chef_zero.rb +7 -5
- data/lib/kitchen/transport/winrm.rb +36 -2
- data/lib/kitchen/verifier/base.rb +18 -1
- data/lib/kitchen/verifier/busser.rb +12 -5
- data/lib/kitchen/verifier/shell.rb +101 -0
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/configurable_spec.rb +211 -2
- data/spec/kitchen/driver/ssh_base_spec.rb +131 -8
- data/spec/kitchen/lazy_hash_spec.rb +27 -0
- data/spec/kitchen/provisioner/base_spec.rb +25 -0
- data/spec/kitchen/provisioner/chef_base_spec.rb +133 -252
- data/spec/kitchen/provisioner/chef_solo_spec.rb +17 -0
- data/spec/kitchen/provisioner/chef_zero_spec.rb +14 -2
- data/spec/kitchen/provisioner/shell_spec.rb +60 -12
- data/spec/kitchen/transport/winrm_spec.rb +50 -0
- data/spec/kitchen/verifier/base_spec.rb +26 -0
- data/spec/kitchen/verifier/busser_spec.rb +69 -3
- data/spec/kitchen/verifier/shell_spec.rb +157 -0
- data/support/busser_install_command.sh +1 -2
- data/test-kitchen.gemspec +10 -2
- metadata +86 -6
@@ -87,4 +87,31 @@ describe Kitchen::LazyHash do
|
|
87
87
|
converted.fetch(:genre).must_equal "heavy metal"
|
88
88
|
end
|
89
89
|
end
|
90
|
+
|
91
|
+
describe "select" do
|
92
|
+
it "calls Procs when appropriate" do
|
93
|
+
Kitchen::LazyHash.new(hash_obj, context).select { |_, _| true }.
|
94
|
+
must_equal :shed_color => "blue", :barn => "locked", :genre => "heavy metal"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "enumerable" do
|
99
|
+
it "is an Enumerable" do
|
100
|
+
assert Kitchen::LazyHash.new(hash_obj, context).is_a? Enumerable
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns an Enumerator from each() if no block given" do
|
104
|
+
e = Kitchen::LazyHash.new(hash_obj, context).each
|
105
|
+
e.is_a? Enumerator
|
106
|
+
e.next.must_equal [:shed_color, "blue"]
|
107
|
+
e.next.must_equal [:barn, "locked"]
|
108
|
+
e.next.must_equal [:genre, "heavy metal"]
|
109
|
+
end
|
110
|
+
|
111
|
+
it "yields each item to the block if a block is given to each()" do
|
112
|
+
items = []
|
113
|
+
Kitchen::LazyHash.new(hash_obj, context).each { |i| items << i }
|
114
|
+
items.must_equal [[:shed_color, "blue"], [:barn, "locked"], [:genre, "heavy metal"]]
|
115
|
+
end
|
116
|
+
end
|
90
117
|
end
|
@@ -131,6 +131,10 @@ describe Kitchen::Provisioner::Base do
|
|
131
131
|
it ":http_proxys defaults to nil" do
|
132
132
|
provisioner[:https_proxy].must_equal nil
|
133
133
|
end
|
134
|
+
|
135
|
+
it ":ftp_proxy defaults to nil" do
|
136
|
+
provisioner[:ftp_proxy].must_equal nil
|
137
|
+
end
|
134
138
|
end
|
135
139
|
|
136
140
|
describe "#call" do
|
@@ -325,4 +329,25 @@ describe Kitchen::Provisioner::Base do
|
|
325
329
|
end
|
326
330
|
end
|
327
331
|
end
|
332
|
+
|
333
|
+
describe "#prefix_command" do
|
334
|
+
|
335
|
+
describe "with :command_prefix set" do
|
336
|
+
|
337
|
+
before { config[:command_prefix] = "my_prefix" }
|
338
|
+
|
339
|
+
it "prepends the command with the prefix" do
|
340
|
+
provisioner.send(:prefix_command, "my_command").must_equal("my_prefix my_command")
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
describe "with :command_prefix unset" do
|
345
|
+
|
346
|
+
before { config[:command_prefix] = nil }
|
347
|
+
|
348
|
+
it "returns an unaltered command" do
|
349
|
+
provisioner.send(:prefix_command, "my_command").must_equal("my_command")
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
328
353
|
end
|
@@ -27,6 +27,7 @@ describe Kitchen::Provisioner::ChefBase do
|
|
27
27
|
let(:logger) { Logger.new(logged_output) }
|
28
28
|
let(:platform) { stub(:os_type => nil) }
|
29
29
|
let(:suite) { stub(:name => "fries") }
|
30
|
+
let(:default_version) { "" }
|
30
31
|
|
31
32
|
let(:config) do
|
32
33
|
{ :test_base_path => "/basist", :kitchen_root => "/rooty" }
|
@@ -55,10 +56,6 @@ describe Kitchen::Provisioner::ChefBase do
|
|
55
56
|
|
56
57
|
before { platform.stubs(:os_type).returns("unix") }
|
57
58
|
|
58
|
-
it ":chef_omnibus_root has a default" do
|
59
|
-
provisioner[:chef_omnibus_root].must_equal "/opt/chef"
|
60
|
-
end
|
61
|
-
|
62
59
|
it ":chef_omnibus_url has a default" do
|
63
60
|
provisioner[:chef_omnibus_url].
|
64
61
|
must_equal "https://www.chef.io/chef/install.sh"
|
@@ -73,109 +70,11 @@ describe Kitchen::Provisioner::ChefBase do
|
|
73
70
|
|
74
71
|
before { platform.stubs(:os_type).returns("windows") }
|
75
72
|
|
76
|
-
it ":chef_omnibus_root has a default" do
|
77
|
-
provisioner[:chef_omnibus_root].
|
78
|
-
must_equal "$env:systemdrive\\opscode\\chef"
|
79
|
-
end
|
80
|
-
|
81
73
|
it ":chef_omnibus_url has a default" do
|
82
74
|
provisioner[:chef_omnibus_url].
|
83
75
|
must_equal "https://www.chef.io/chef/install.sh"
|
84
76
|
end
|
85
77
|
|
86
|
-
describe ":chef_metadata_url" do
|
87
|
-
|
88
|
-
let(:base_url) { "https://www.chef.io/chef/metadata" }
|
89
|
-
|
90
|
-
it "uses :chef_omnibus_url as url base if it ends in install.sh" do
|
91
|
-
config[:chef_omnibus_url] = "https://woot/install.sh"
|
92
|
-
|
93
|
-
provisioner[:chef_metadata_url].must_equal(
|
94
|
-
"https://woot/metadata?p=windows&m=x86_64&pv=2008r2&v=latest"
|
95
|
-
)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "ignores :chef_omnibus_url if it doesn't end in install.sh" do
|
99
|
-
config[:chef_omnibus_url] = "https://woot/other"
|
100
|
-
|
101
|
-
provisioner[:chef_metadata_url].
|
102
|
-
must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=latest"
|
103
|
-
end
|
104
|
-
|
105
|
-
it "defaults to latest package with :require_chef_omnibus = true" do
|
106
|
-
config[:require_chef_omnibus] = true
|
107
|
-
|
108
|
-
provisioner[:chef_metadata_url].
|
109
|
-
must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=latest"
|
110
|
-
end
|
111
|
-
|
112
|
-
it "defaults to latest package with :require_chef_omnibus = latest" do
|
113
|
-
config[:require_chef_omnibus] = "latest"
|
114
|
-
|
115
|
-
provisioner[:chef_metadata_url].
|
116
|
-
must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=latest"
|
117
|
-
end
|
118
|
-
|
119
|
-
it "defaults to a specific package from :require_chef_omnibus" do
|
120
|
-
config[:require_chef_omnibus] = "11.12.13"
|
121
|
-
|
122
|
-
provisioner[:chef_metadata_url].
|
123
|
-
must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=11.12.13"
|
124
|
-
end
|
125
|
-
|
126
|
-
it "defaults to a maj/min version package from :require_chef_omnibus" do
|
127
|
-
config[:require_chef_omnibus] = 12.1
|
128
|
-
|
129
|
-
provisioner[:chef_metadata_url].
|
130
|
-
must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=12.1"
|
131
|
-
end
|
132
|
-
|
133
|
-
it "defaults to a major package version from :require_chef_omnibus" do
|
134
|
-
config[:require_chef_omnibus] = "16"
|
135
|
-
|
136
|
-
provisioner[:chef_metadata_url].
|
137
|
-
must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=16"
|
138
|
-
end
|
139
|
-
|
140
|
-
it "defaults to a prerelease package from :require_chef_omnibus" do
|
141
|
-
config[:require_chef_omnibus] = "11.6.0.RC.1"
|
142
|
-
|
143
|
-
provisioner[:chef_metadata_url].
|
144
|
-
must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=11.6.0.rc.1"
|
145
|
-
end
|
146
|
-
|
147
|
-
it "defaults to a nightly package from :require_chef_omnibus" do
|
148
|
-
config[:require_chef_omnibus] = "12.5.0-current.0+20150721082808.git.14.c91b337-1"
|
149
|
-
|
150
|
-
provisioner[:chef_metadata_url].
|
151
|
-
must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&" \
|
152
|
-
"v=12.5.0-current.0%2B20150721082808.git.14.c91b337-1"
|
153
|
-
end
|
154
|
-
|
155
|
-
it "defaults to a chefdk package from :chef_omnibus_install_options" do
|
156
|
-
config[:require_chef_omnibus] = true
|
157
|
-
config[:chef_omnibus_install_options] = "-P chefdk"
|
158
|
-
|
159
|
-
provisioner[:chef_metadata_url].
|
160
|
-
must_equal "#{base_url}-chefdk?p=windows&m=x86_64&pv=2008r2&v=latest"
|
161
|
-
end
|
162
|
-
|
163
|
-
it "defaults to a specfic chefdk from :chef_omnibus_install_options" do
|
164
|
-
config[:require_chef_omnibus] = "0.3.6"
|
165
|
-
config[:chef_omnibus_install_options] = "-a other -P chefdk -B okay"
|
166
|
-
|
167
|
-
provisioner[:chef_metadata_url].
|
168
|
-
must_equal "#{base_url}-chefdk?p=windows&m=x86_64&pv=2008r2&v=0.3.6"
|
169
|
-
end
|
170
|
-
|
171
|
-
it "defaults to a maj/min chefdk from :chef_omnibus_install_options" do
|
172
|
-
config[:require_chef_omnibus] = "0.3"
|
173
|
-
config[:chef_omnibus_install_options] = "-P chefdk -B okay"
|
174
|
-
|
175
|
-
provisioner[:chef_metadata_url].
|
176
|
-
must_equal "#{base_url}-chefdk?p=windows&m=x86_64&pv=2008r2&v=0.3"
|
177
|
-
end
|
178
|
-
end
|
179
78
|
end
|
180
79
|
|
181
80
|
it ":require_chef_omnibus defaults to true" do
|
@@ -240,259 +139,241 @@ describe Kitchen::Provisioner::ChefBase do
|
|
240
139
|
|
241
140
|
describe "#install_command" do
|
242
141
|
|
243
|
-
|
142
|
+
before do
|
143
|
+
platform.stubs(:shell_type).returns("bourne")
|
144
|
+
Mixlib::Install.stubs(:new).returns(installer)
|
145
|
+
end
|
244
146
|
|
245
|
-
|
147
|
+
let(:installer) { stub(:root => "/rooty", :install_command => "make_it_so") }
|
246
148
|
|
247
|
-
|
149
|
+
let(:cmd) { provisioner.install_command }
|
248
150
|
|
249
|
-
|
250
|
-
|
151
|
+
let(:install_opts) {
|
152
|
+
{ :omnibus_url => "https://www.chef.io/chef/install.sh",
|
153
|
+
:project => nil, :install_flags => nil, :http_proxy => nil,
|
154
|
+
:https_proxy => nil }
|
155
|
+
}
|
251
156
|
|
252
|
-
|
253
|
-
|
157
|
+
it "returns nil if :require_chef_omnibus is falsey" do
|
158
|
+
config[:require_chef_omnibus] = false
|
254
159
|
|
255
|
-
|
256
|
-
|
160
|
+
installer.expects(:root).never
|
161
|
+
installer.expects(:install_command).never
|
162
|
+
cmd.must_equal nil
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "common behaviour" do
|
166
|
+
before do
|
167
|
+
installer.expects(:root).at_least_once.returns("/opt/chef")
|
168
|
+
installer.expects(:install_command)
|
257
169
|
end
|
258
170
|
|
259
|
-
it "
|
260
|
-
|
171
|
+
it "passes sensible defaults" do
|
172
|
+
Mixlib::Install.expects(:new).
|
173
|
+
with(default_version, false, install_opts).returns(installer)
|
174
|
+
cmd
|
261
175
|
end
|
262
176
|
|
263
177
|
it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
|
264
178
|
config[:http_proxy] = "http://proxy"
|
179
|
+
install_opts[:http_proxy] = "http://proxy"
|
265
180
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
])
|
181
|
+
Mixlib::Install.expects(:new).
|
182
|
+
with(default_version, false, install_opts).returns(installer)
|
183
|
+
cmd
|
270
184
|
end
|
271
185
|
|
272
186
|
it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
|
273
187
|
config[:https_proxy] = "https://proxy"
|
188
|
+
install_opts[:https_proxy] = "https://proxy"
|
274
189
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
])
|
190
|
+
Mixlib::Install.expects(:new).
|
191
|
+
with(default_version, false, install_opts).returns(installer)
|
192
|
+
cmd
|
279
193
|
end
|
280
194
|
|
281
195
|
it "exports all http proxy variables when both are set" do
|
282
196
|
config[:http_proxy] = "http://proxy"
|
283
197
|
config[:https_proxy] = "https://proxy"
|
198
|
+
install_opts[:http_proxy] = "http://proxy"
|
199
|
+
install_opts[:https_proxy] = "https://proxy"
|
284
200
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
%{https_proxy="https://proxy"; export https_proxy\n},
|
289
|
-
%{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n}
|
290
|
-
])
|
201
|
+
Mixlib::Install.expects(:new).
|
202
|
+
with(default_version, false, install_opts).returns(installer)
|
203
|
+
cmd
|
291
204
|
end
|
292
205
|
|
293
206
|
it "installs chef using :chef_omnibus_url, if necessary" do
|
294
207
|
config[:chef_omnibus_url] = "FROM_HERE"
|
208
|
+
install_opts[:omnibus_url] = "FROM_HERE"
|
295
209
|
|
296
|
-
|
210
|
+
Mixlib::Install.expects(:new).
|
211
|
+
with(default_version, false, install_opts).returns(installer)
|
212
|
+
cmd
|
297
213
|
end
|
298
214
|
|
299
215
|
it "will install a specific version of chef, if necessary" do
|
300
216
|
config[:require_chef_omnibus] = "1.2.3"
|
301
217
|
|
302
|
-
|
303
|
-
|
304
|
-
cmd
|
218
|
+
Mixlib::Install.expects(:new).
|
219
|
+
with("1.2.3", false, install_opts).returns(installer)
|
220
|
+
cmd
|
305
221
|
end
|
306
222
|
|
307
223
|
it "will install a major/minor version of chef, if necessary" do
|
308
224
|
config[:require_chef_omnibus] = "11.10"
|
309
225
|
|
310
|
-
|
311
|
-
|
312
|
-
cmd
|
226
|
+
Mixlib::Install.expects(:new).
|
227
|
+
with("11.10", false, install_opts).returns(installer)
|
228
|
+
cmd
|
313
229
|
end
|
314
230
|
|
315
231
|
it "will install a major version of chef, if necessary" do
|
316
232
|
config[:require_chef_omnibus] = "12"
|
317
233
|
|
318
|
-
|
319
|
-
|
320
|
-
cmd
|
234
|
+
Mixlib::Install.expects(:new).
|
235
|
+
with("12", false, install_opts).returns(installer)
|
236
|
+
cmd
|
321
237
|
end
|
322
238
|
|
323
239
|
it "will install a downcaased version string of chef, if necessary" do
|
324
240
|
config[:require_chef_omnibus] = "10.1.0.RC.1"
|
325
241
|
|
326
|
-
|
327
|
-
|
328
|
-
cmd
|
242
|
+
Mixlib::Install.expects(:new).
|
243
|
+
with("10.1.0.rc.1", false, install_opts).returns(installer)
|
244
|
+
cmd
|
329
245
|
end
|
330
246
|
|
331
247
|
it "will install a nightly, if necessary" do
|
332
|
-
config[:require_chef_omnibus] =
|
248
|
+
config[:require_chef_omnibus] =
|
249
|
+
"12.5.0-current.0+20150721082808.git.14.c91b337-1"
|
333
250
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
251
|
+
Mixlib::Install.expects(:new).with(
|
252
|
+
"12.5.0-current.0+20150721082808.git.14.c91b337-1",
|
253
|
+
false,
|
254
|
+
install_opts
|
255
|
+
).returns(installer)
|
256
|
+
cmd
|
340
257
|
end
|
341
258
|
|
342
|
-
it "will install the latest
|
259
|
+
it "will install the latest chef, if necessary" do
|
343
260
|
config[:require_chef_omnibus] = "latest"
|
344
261
|
|
345
|
-
|
346
|
-
|
347
|
-
cmd
|
262
|
+
Mixlib::Install.expects(:new).
|
263
|
+
with("latest", false, install_opts).returns(installer)
|
264
|
+
cmd
|
348
265
|
end
|
349
266
|
|
350
|
-
it "will install a of chef, unless it exists" do
|
267
|
+
it "will install a version of chef, unless it exists" do
|
351
268
|
config[:require_chef_omnibus] = true
|
352
269
|
|
353
|
-
|
354
|
-
|
355
|
-
cmd
|
270
|
+
Mixlib::Install.expects(:new).
|
271
|
+
with(default_version, false, install_opts).returns(installer)
|
272
|
+
cmd
|
356
273
|
end
|
357
274
|
|
358
|
-
it "will pass
|
275
|
+
it "will pass a project, when given" do
|
359
276
|
config[:chef_omnibus_install_options] = "-P chefdk"
|
277
|
+
install_opts[:install_flags] = "-P chefdk"
|
278
|
+
install_opts[:project] = "chefdk"
|
360
279
|
|
361
|
-
|
362
|
-
|
363
|
-
cmd
|
280
|
+
Mixlib::Install.expects(:new).
|
281
|
+
with(default_version, false, install_opts).returns(installer)
|
282
|
+
cmd
|
364
283
|
end
|
365
284
|
|
366
285
|
it "will pass install options and version info, when given" do
|
367
286
|
config[:require_chef_omnibus] = "11"
|
368
287
|
config[:chef_omnibus_install_options] = "-d /tmp/place"
|
288
|
+
install_opts[:install_flags] = "-d /tmp/place"
|
369
289
|
|
370
|
-
|
371
|
-
|
372
|
-
cmd
|
290
|
+
Mixlib::Install.expects(:new).
|
291
|
+
with("11", false, install_opts).returns(installer)
|
292
|
+
cmd
|
373
293
|
end
|
374
294
|
|
375
|
-
it "
|
376
|
-
config[:
|
295
|
+
it "will set the install root" do
|
296
|
+
config[:chef_omnibus_root] = "/tmp/test"
|
297
|
+
install_opts[:root] = "/tmp/test"
|
377
298
|
|
378
|
-
|
299
|
+
Mixlib::Install.expects(:new).
|
300
|
+
with(default_version, false, install_opts).returns(installer)
|
301
|
+
cmd
|
379
302
|
end
|
380
303
|
|
381
|
-
it "
|
382
|
-
config[:
|
304
|
+
it "prefixs the whole command with the command_prefix if set" do
|
305
|
+
config[:command_prefix] = "my_prefix"
|
383
306
|
|
384
|
-
cmd.must_match
|
307
|
+
cmd.must_match(/\Amy_prefix /)
|
385
308
|
end
|
386
|
-
end
|
387
309
|
|
388
|
-
|
389
|
-
|
390
|
-
before do
|
391
|
-
platform.stubs(:shell_type).returns("powershell")
|
392
|
-
platform.stubs(:os_type).returns("windows")
|
393
|
-
end
|
394
|
-
|
395
|
-
it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
|
396
|
-
config[:http_proxy] = "http://proxy"
|
397
|
-
|
398
|
-
cmd.lines.to_a[0..1].must_equal([
|
399
|
-
%{$env:http_proxy = "http://proxy"\n},
|
400
|
-
%{$env:HTTP_PROXY = "http://proxy"\n}
|
401
|
-
])
|
402
|
-
end
|
403
|
-
|
404
|
-
it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
|
405
|
-
config[:https_proxy] = "https://proxy"
|
406
|
-
|
407
|
-
cmd.lines.to_a[0..1].must_equal([
|
408
|
-
%{$env:https_proxy = "https://proxy"\n},
|
409
|
-
%{$env:HTTPS_PROXY = "https://proxy"\n}
|
410
|
-
])
|
411
|
-
end
|
412
|
-
|
413
|
-
it "exports all http proxy variables when both are set" do
|
414
|
-
config[:http_proxy] = "http://proxy"
|
415
|
-
config[:https_proxy] = "https://proxy"
|
416
|
-
|
417
|
-
cmd.lines.to_a[0..3].must_equal([
|
418
|
-
%{$env:http_proxy = "http://proxy"\n},
|
419
|
-
%{$env:HTTP_PROXY = "http://proxy"\n},
|
420
|
-
%{$env:https_proxy = "https://proxy"\n},
|
421
|
-
%{$env:HTTPS_PROXY = "https://proxy"\n}
|
422
|
-
])
|
423
|
-
end
|
424
|
-
|
425
|
-
it "returns nil if :require_chef_omnibus is falsey" do
|
426
|
-
config[:require_chef_omnibus] = false
|
310
|
+
it "does not prefix the command if command_prefix is not set" do
|
311
|
+
config[:command_prefix] = nil
|
427
312
|
|
428
|
-
cmd.
|
313
|
+
cmd.wont_match(/\Amy_prefix /)
|
429
314
|
end
|
315
|
+
end
|
430
316
|
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
317
|
+
describe "for bourne shells" do
|
318
|
+
before do
|
319
|
+
installer.expects(:root).at_least_once.returns("/opt/chef")
|
320
|
+
installer.expects(:install_command).returns("my_install_command")
|
435
321
|
end
|
436
322
|
|
437
|
-
it "
|
438
|
-
config[:
|
323
|
+
it "prepends sudo for sh commands when :sudo is set" do
|
324
|
+
config[:sudo] = true
|
325
|
+
config[:sudo_command] = "my_sudo_command"
|
439
326
|
|
440
|
-
|
327
|
+
Mixlib::Install.expects(:new).
|
328
|
+
with(default_version, false, install_opts).returns(installer)
|
329
|
+
cmd.must_equal "my_sudo_command my_install_command"
|
441
330
|
end
|
442
331
|
|
443
|
-
it "
|
444
|
-
config[:
|
332
|
+
it "does not sudo for sh commands when :sudo is falsey" do
|
333
|
+
config[:sudo] = false
|
445
334
|
|
446
|
-
|
335
|
+
Mixlib::Install.expects(:new).
|
336
|
+
with(default_version, false, install_opts).returns(installer)
|
337
|
+
cmd.must_equal "my_install_command"
|
447
338
|
end
|
339
|
+
end
|
448
340
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
341
|
+
describe "for powershell shells on windows os types" do
|
342
|
+
before do
|
343
|
+
installer.expects(:root).at_least_once.returns("/opt/chef")
|
344
|
+
installer.expects(:install_command)
|
345
|
+
platform.stubs(:shell_type).returns("powershell")
|
346
|
+
platform.stubs(:os_type).returns("windows")
|
454
347
|
end
|
455
348
|
|
456
|
-
it "
|
457
|
-
|
458
|
-
|
459
|
-
cmd
|
460
|
-
cmd.must_match regexify(%{$version = "11.10"})
|
349
|
+
it "sets the powershell flag for Mixlib::Install" do
|
350
|
+
Mixlib::Install.expects(:new).
|
351
|
+
with(default_version, true, install_opts).returns(installer)
|
352
|
+
cmd
|
461
353
|
end
|
354
|
+
end
|
355
|
+
end
|
462
356
|
|
463
|
-
|
464
|
-
config[:require_chef_omnibus] = "12"
|
357
|
+
describe "#init_command" do
|
465
358
|
|
466
|
-
|
467
|
-
cmd.must_match regexify(%{$version = "12"})
|
468
|
-
end
|
359
|
+
let(:cmd) { provisioner.init_command }
|
469
360
|
|
470
|
-
|
471
|
-
config[:require_chef_omnibus] = "10.1.0.RC.1"
|
361
|
+
describe "common behavior" do
|
472
362
|
|
473
|
-
|
474
|
-
cmd.must_match regexify(%{$version = "10.1.0.rc.1"})
|
475
|
-
end
|
363
|
+
before { platform.stubs(:shell_type).returns("fake") }
|
476
364
|
|
477
|
-
it "
|
478
|
-
config[:
|
365
|
+
it "prefixs the whole command with the command_prefix if set" do
|
366
|
+
config[:command_prefix] = "my_prefix"
|
479
367
|
|
480
|
-
cmd.must_match
|
481
|
-
cmd.must_match regexify(%{$version = "latest"})
|
368
|
+
cmd.must_match(/\Amy_prefix /)
|
482
369
|
end
|
483
370
|
|
484
|
-
it "
|
485
|
-
config[:
|
371
|
+
it "does not prefix the command if command_prefix is not set" do
|
372
|
+
config[:command_prefix] = nil
|
486
373
|
|
487
|
-
cmd.
|
488
|
-
cmd.must_match regexify(%{$version = "true"})
|
374
|
+
cmd.wont_match(/\Amy_prefix /)
|
489
375
|
end
|
490
376
|
end
|
491
|
-
end
|
492
|
-
|
493
|
-
describe "#init_command" do
|
494
|
-
|
495
|
-
let(:cmd) { provisioner.init_command }
|
496
377
|
|
497
378
|
describe "for bourne shells" do
|
498
379
|
|