clc-promote 0.8.7 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -1
- data/clc-promote.gemspec +1 -1
- data/lib/promote/cookbook.rb +2 -2
- data/lib/promote/node_finder.rb +7 -5
- data/lib/promote/promoter.rb +16 -11
- data/lib/promote/version.rb +1 -1
- data/spec/unit/promote/config_spec.rb +137 -126
- data/spec/unit/promote/cookbook_spec.rb +34 -34
- data/spec/unit/promote/promoter_spec.rb +86 -49
- data/spec/unit/promote/uploader_spec.rb +285 -285
- data/spec/unit/promote/versioner_spec.rb +339 -316
- metadata +3 -3
@@ -2,181 +2,194 @@ require 'promote'
|
|
2
2
|
require_relative '../support/dummy_log'
|
3
3
|
|
4
4
|
describe Promote::Versioner do
|
5
|
-
before(:all)
|
5
|
+
before(:all) do
|
6
6
|
cb_dir = '/tmp/promote_test_cookbooks'
|
7
7
|
FileUtils.rm_rf(cb_dir) if Dir.exist?(cb_dir)
|
8
8
|
Dir.mkdir(cb_dir)
|
9
|
-
FileUtils.cp_r(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
9
|
+
FileUtils.cp_r(
|
10
|
+
File.join(File.dirname(File.dirname(__FILE__)), 'stubs'),
|
11
|
+
cb_dir
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:cookbook_dir) { '/tmp/promote_test_cookbooks/stubs' }
|
16
|
+
let(:test_cookbook) { 'cookbook_1' }
|
17
|
+
let(:config) { Promote::Config.new(cookbook_directory: cookbook_dir) }
|
18
|
+
let(:fake_file) { double('file') }
|
19
|
+
|
20
|
+
let(:artifact_file) { '' }
|
21
|
+
let(:fake_berks) { double('berksfile', install: nil) }
|
22
|
+
before do
|
23
|
+
allow(Berkshelf::Berksfile).to receive(:from_file).and_return(fake_berks)
|
24
|
+
allow_any_instance_of(Promote::GitRepo).to receive(:git)
|
25
|
+
.and_return(Git::Base.new)
|
26
|
+
allow_any_instance_of(Git::Base).to receive(:tags).and_return([
|
27
|
+
double('tag', name: '1.0', sha: 'abc'),
|
28
|
+
double('tag', name: '1.1', sha: 'def'),
|
29
|
+
double('tag', name: '1.2', sha: 'ghi')
|
30
|
+
])
|
31
|
+
allow_any_instance_of(Git::Base).to receive(:log).with(10_000).and_return(
|
32
|
+
PromoteSpecs::DummyLog.new([
|
33
|
+
{ msg: 'blah', sha: 'aaa' },
|
34
|
+
{ msg: 'CI:bumping', sha: 'bbb' },
|
35
|
+
{ msg: 'blah', sha: 'ccc' }
|
36
|
+
]))
|
37
|
+
end
|
35
38
|
|
36
39
|
subject { Promote::Versioner.new(config) }
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
41
|
+
context 'version_cookbook' do
|
42
|
+
context 'when versioning a new cookbook version' do
|
43
|
+
let(:cookbook) { Promote::Cookbook.new(test_cookbook, config) }
|
44
|
+
it 'writes the new version and sha to the file' do
|
45
|
+
subject.version_cookbook(test_cookbook)
|
46
|
+
expect(cookbook.version.to_s).to eq('1.2.2')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'adds the new version and sha to the cookbook' do
|
50
|
+
subject.version_cookbook(test_cookbook)
|
51
|
+
expect(cookbook.raw_metadata).to end_with("#sha1 'aaa'")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when versioning a cookbook with no changes' do
|
56
|
+
it 'does not write to metadata rb' do
|
57
|
+
expect(subject.version_cookbook(test_cookbook)).to be nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'version_cookbooks' do
|
63
|
+
let(:cookbooks) do
|
64
|
+
[
|
65
|
+
File.join(subject.config.cookbook_directory, 'cookbook1'),
|
66
|
+
File.join(subject.config.cookbook_directory, 'cookbook2'),
|
67
|
+
File.join(subject.config.cookbook_directory, 'cookbook3')
|
68
|
+
]
|
69
|
+
end
|
70
|
+
before do
|
71
|
+
allow(subject).to receive(:version_cookbook)
|
72
|
+
allow(Dir).to receive(:glob).with(
|
73
|
+
File.join(subject.config.cookbook_directory, '*')).and_return(cookbooks)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'versions each cookbook' do
|
77
|
+
cookbooks.each do |cookbook|
|
78
|
+
expect(subject).to receive(:version_cookbook)
|
79
|
+
.with(File.basename(cookbook))
|
80
|
+
end
|
81
|
+
subject.version_cookbooks
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'version_environment' do
|
86
|
+
before do
|
87
|
+
regex = File.join(config.environment_directory, 'test.json')
|
88
|
+
allow(File).to receive(:read).with(regex).and_return(artifact_file)
|
89
|
+
allow(File).to receive(:open).with(regex, 'w').and_yield(fake_file)
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when versioning a new environment with no version' do
|
93
|
+
let(:artifact_file) do
|
94
|
+
<<-EOS
|
95
|
+
{
|
96
|
+
"name": "QA1",
|
97
|
+
"chef_type": "environment",
|
98
|
+
"json_class": "Chef::Environment",
|
99
|
+
"override_attributes": {
|
100
|
+
"environment_parent": "QA"
|
101
|
+
}
|
102
|
+
}
|
103
|
+
EOS
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'writes the new version and sha to the file' do
|
107
|
+
parsed = JSON.parse(artifact_file)
|
108
|
+
parsed['override_attributes']['version'] = '1.2.2'
|
109
|
+
parsed['override_attributes']['sha1'] = 'aaa'
|
110
|
+
expect(fake_file).to receive(:<<).with(JSON.pretty_generate(parsed))
|
111
|
+
subject.version_environment('test')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'when versioning a new environment with old version' do
|
116
|
+
let(:artifact_file) do
|
117
|
+
<<-EOS
|
118
|
+
{
|
119
|
+
"name": "QA1",
|
120
|
+
"chef_type": "environment",
|
121
|
+
"json_class": "Chef::Environment",
|
122
|
+
"override_attributes": {
|
123
|
+
"environment_parent": "QA",
|
124
|
+
"version": "1.0.0",
|
125
|
+
"sha1": "ccc"
|
126
|
+
}
|
127
|
+
}
|
128
|
+
EOS
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'writes the new version and sha to the file' do
|
132
|
+
parsed = JSON.parse(artifact_file)
|
133
|
+
parsed['override_attributes']['version'] = '1.2.2'
|
134
|
+
parsed['override_attributes']['sha1'] = 'aaa'
|
135
|
+
expect(fake_file).to receive(:<<).with(JSON.pretty_generate(parsed))
|
136
|
+
subject.version_environment('test')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when commiting an environment with no changes' do
|
141
|
+
let(:artifact_file) do
|
142
|
+
<<-EOS
|
143
|
+
{
|
144
|
+
"name": "QA1",
|
145
|
+
"chef_type": "environment",
|
146
|
+
"json_class": "Chef::Environment",
|
147
|
+
"override_attributes": {
|
148
|
+
"environment_parent": "QA",
|
149
|
+
"version": "1.2.2",
|
150
|
+
"sha1": "aaa"
|
151
|
+
}
|
152
|
+
}
|
153
|
+
EOS
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'does not write to the file' do
|
157
|
+
expect(fake_file).not_to receive(:<<)
|
158
|
+
subject.version_environment('test')
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context 'version_environments' do
|
164
|
+
let(:environments) do
|
165
|
+
[
|
166
|
+
'dir/environment1.json',
|
167
|
+
'dir/environment2.json',
|
168
|
+
'dir/environment3.json'
|
169
|
+
]
|
170
|
+
end
|
171
|
+
before do
|
172
|
+
allow(subject).to receive(:version_environment)
|
173
|
+
allow(Dir).to receive(:glob).with(
|
174
|
+
File.join(subject.config.environment_directory, '*.json'))
|
175
|
+
.and_return(environments)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'versions each environment' do
|
179
|
+
environments.each do |environment|
|
180
|
+
expect(subject).to receive(:version_environment).with(
|
181
|
+
File.basename(environment, File.extname(environment)))
|
182
|
+
end
|
183
|
+
subject.version_environments
|
184
|
+
end
|
185
|
+
end
|
173
186
|
|
174
187
|
context 'version_role' do
|
175
|
-
before
|
176
|
-
regex = File.join(config.role_directory,'test.json')
|
188
|
+
before do
|
189
|
+
regex = File.join(config.role_directory, 'test.json')
|
177
190
|
allow(File).to receive(:read).with(regex).and_return(artifact_file)
|
178
|
-
allow(File).to receive(:open).with(regex,
|
179
|
-
|
191
|
+
allow(File).to receive(:open).with(regex, 'w').and_yield(fake_file)
|
192
|
+
end
|
180
193
|
|
181
194
|
context 'when versioning a new role with no version' do
|
182
195
|
let(:artifact_file) do
|
@@ -191,7 +204,7 @@ describe Promote::Versioner do
|
|
191
204
|
}
|
192
205
|
EOS
|
193
206
|
end
|
194
|
-
it
|
207
|
+
it 'writes the new version and sha to the file' do
|
195
208
|
parsed = JSON.parse(artifact_file)
|
196
209
|
parsed['override_attributes']['version'] = '1.2.2'
|
197
210
|
parsed['override_attributes']['sha1'] = 'aaa'
|
@@ -210,9 +223,9 @@ describe Promote::Versioner do
|
|
210
223
|
}
|
211
224
|
EOS
|
212
225
|
end
|
213
|
-
it
|
226
|
+
it 'adds an override_attributes key to the role' do
|
214
227
|
parsed = JSON.parse(artifact_file)
|
215
|
-
override_hash = {
|
228
|
+
override_hash = { 'override_attributes' => {} }
|
216
229
|
parsed.merge!(override_hash)
|
217
230
|
expect(fake_file).to receive(:<<).with(JSON.pretty_generate(parsed))
|
218
231
|
subject.version_role('test')
|
@@ -220,7 +233,6 @@ describe Promote::Versioner do
|
|
220
233
|
end
|
221
234
|
|
222
235
|
context 'when versioning a new role with old version' do
|
223
|
-
|
224
236
|
let(:artifact_file) do
|
225
237
|
<<-EOS
|
226
238
|
{
|
@@ -236,7 +248,7 @@ describe Promote::Versioner do
|
|
236
248
|
EOS
|
237
249
|
end
|
238
250
|
|
239
|
-
it
|
251
|
+
it 'writes the new version and sha to the file' do
|
240
252
|
parsed = JSON.parse(artifact_file)
|
241
253
|
parsed['override_attributes']['version'] = '1.2.2'
|
242
254
|
parsed['override_attributes']['sha1'] = 'aaa'
|
@@ -261,7 +273,7 @@ describe Promote::Versioner do
|
|
261
273
|
EOS
|
262
274
|
end
|
263
275
|
|
264
|
-
it
|
276
|
+
it 'does not write to the file' do
|
265
277
|
expect(fake_file).not_to receive(:<<)
|
266
278
|
subject.version_role('test')
|
267
279
|
end
|
@@ -269,158 +281,169 @@ describe Promote::Versioner do
|
|
269
281
|
end
|
270
282
|
|
271
283
|
context 'version_roles' do
|
272
|
-
let(:roles) {%w
|
273
|
-
before
|
284
|
+
let(:roles) { %w(dir/role1.json dir/role2.json dir/role3.json) }
|
285
|
+
before do
|
274
286
|
allow(subject).to receive(:version_role)
|
275
287
|
allow(Dir).to receive(:glob).with(
|
276
|
-
|
277
|
-
|
288
|
+
File.join(subject.config.role_directory, '*.json')).and_return(roles)
|
289
|
+
end
|
278
290
|
|
279
|
-
it
|
291
|
+
it 'versions each role' do
|
280
292
|
roles.each do |role|
|
281
293
|
expect(subject).to receive(:version_role).with(
|
282
|
-
|
294
|
+
File.basename(role, File.extname(role)))
|
283
295
|
end
|
284
296
|
subject.version_roles
|
285
297
|
end
|
286
298
|
end
|
287
299
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
300
|
+
context 'constrain_environment' do
|
301
|
+
before do
|
302
|
+
regex = File.join(config.environment_directory, 'test.json')
|
303
|
+
allow(File).to receive(:read).with(regex).and_return(artifact_file)
|
304
|
+
allow(File).to receive(:open).with(regex, 'w').and_yield(fake_file)
|
305
|
+
end
|
306
|
+
|
307
|
+
let(:artifact_file) do
|
308
|
+
<<-EOS
|
309
|
+
{
|
310
|
+
"name": "QA1",
|
311
|
+
"chef_type": "environment",
|
312
|
+
"json_class": "Chef::Environment"
|
313
|
+
}
|
314
|
+
EOS
|
315
|
+
end
|
316
|
+
before do
|
317
|
+
allow(File).to receive(:exist?).with(/Berksfile$/).and_return(true)
|
318
|
+
allow(fake_berks).to receive(:list).and_return([
|
319
|
+
double(
|
320
|
+
'Dependency',
|
321
|
+
name: 'cookbook1',
|
322
|
+
locked_version: Semverse::Version.new('1.1.1')
|
323
|
+
),
|
324
|
+
double(
|
325
|
+
'Dependency',
|
326
|
+
name: 'cookbook2',
|
327
|
+
locked_version: Semverse::Version.new('2.2.2')
|
328
|
+
),
|
329
|
+
double(
|
330
|
+
'Dependency',
|
331
|
+
name: 'cookbook3',
|
332
|
+
locked_version:
|
333
|
+
Semverse::Version.new('3.3.3')
|
334
|
+
)
|
335
|
+
])
|
336
|
+
end
|
337
|
+
it 'writes the cookbook constraints to the file' do
|
338
|
+
expect(fake_file).to receive(:<<).with(an_instance_of(String)) do |arg|
|
339
|
+
parsed = JSON.parse(arg)
|
340
|
+
expect(parsed['cookbook_versions']['cookbook1']).to eq('1.1.1')
|
341
|
+
expect(parsed['cookbook_versions']['cookbook2']).to eq('2.2.2')
|
342
|
+
expect(parsed['cookbook_versions']['cookbook3']).to eq('3.3.3')
|
343
|
+
end
|
344
|
+
subject.constrain_environment('test', 'test_cookbook')
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
context 'is_dirty' do
|
349
|
+
before do
|
350
|
+
regex = File.join(config.environment_directory, 'test.json')
|
351
|
+
allow(File).to receive(:read).with(regex).and_return(artifact_file)
|
352
|
+
allow(File).to receive(:open).with(regex, 'w').and_yield(fake_file)
|
353
|
+
allow(File).to receive(:read).with(/new.json/).and_return(
|
354
|
+
<<-EOS
|
355
|
+
{
|
356
|
+
"name": "test",
|
357
|
+
"chef_type": "environment",
|
358
|
+
"json_class": "Chef::Environment",
|
359
|
+
"cookbook_versions": {
|
360
|
+
"cookbook1": "1.1.1",
|
361
|
+
"cookbook2": "2.2.2",
|
362
|
+
"cookbook3": "3.3.3"
|
363
|
+
}
|
364
|
+
}
|
365
|
+
EOS
|
366
|
+
)
|
367
|
+
end
|
368
|
+
|
369
|
+
context 'cookbook is dirty' do
|
370
|
+
let(:artifact_file) do
|
371
|
+
<<-EOS
|
372
|
+
{
|
373
|
+
"name": "LKG",
|
374
|
+
"chef_type": "environment",
|
375
|
+
"json_class": "Chef::Environment",
|
376
|
+
"cookbook_versions": {
|
377
|
+
"cookbook1": "1.1.1.hash",
|
378
|
+
"cookbook2": "1.1.1.hash",
|
379
|
+
"cookbook3": "3.3.3.hash"
|
380
|
+
}
|
381
|
+
}
|
382
|
+
EOS
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'returns dirty' do
|
386
|
+
expect(subject.is_dirty('new', 'test', 'cookbook2', 'hash')).to be(true)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
context 'cookbook has same version but different hash' do
|
390
|
+
let(:artifact_file) do
|
391
|
+
<<-EOS
|
392
|
+
{
|
393
|
+
"name": "LKG",
|
394
|
+
"chef_type": "environment",
|
395
|
+
"json_class": "Chef::Environment",
|
396
|
+
"cookbook_versions": {
|
397
|
+
"cookbook1": "1.1.1.hash",
|
398
|
+
"cookbook2": "2.2.2.diff_hash",
|
399
|
+
"cookbook3": "3.3.3.hash"
|
400
|
+
}
|
401
|
+
}
|
402
|
+
EOS
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'returns dirty' do
|
406
|
+
expect(subject.is_dirty('new', 'test', 'cookbook2', 'hash')).to be true
|
407
|
+
end
|
408
|
+
end
|
409
|
+
context 'cookbook is not dirty' do
|
410
|
+
let(:artifact_file) do
|
411
|
+
<<-EOS
|
412
|
+
{
|
413
|
+
"name": "LKG",
|
414
|
+
"chef_type": "environment",
|
415
|
+
"json_class": "Chef::Environment",
|
416
|
+
"cookbook_versions": {
|
417
|
+
"cookbook1": "1.1.1.hash",
|
418
|
+
"cookbook2": "2.2.2.hash",
|
419
|
+
"cookbook3": "3.3.3.hash"
|
420
|
+
}
|
421
|
+
}
|
422
|
+
EOS
|
423
|
+
end
|
424
|
+
|
425
|
+
it 'returns clean' do
|
426
|
+
expect(subject.is_dirty('new', 'test', 'cookbook2', 'hash')).to be false
|
427
|
+
end
|
428
|
+
end
|
429
|
+
context 'cookbook is new to environment' do
|
430
|
+
let(:artifact_file) do
|
431
|
+
<<-EOS
|
432
|
+
{
|
433
|
+
"name": "LKG",
|
434
|
+
"chef_type": "environment",
|
435
|
+
"json_class": "Chef::Environment",
|
436
|
+
"cookbook_versions": {
|
437
|
+
"cookbook1": "1.1.1.hash",
|
438
|
+
"cookbook3": "3.3.3.hash"
|
439
|
+
}
|
440
|
+
}
|
441
|
+
EOS
|
442
|
+
end
|
443
|
+
|
444
|
+
it 'returns dirty' do
|
445
|
+
expect(subject.is_dirty('new', 'test', 'cookbook2', 'hash')).to be true
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
426
449
|
end
|