librarian 0.0.26 → 0.1.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -3
- data/.travis.yml +7 -0
- data/Gemfile +1 -1
- data/{MIT-LICENSE → LICENSE.txt} +2 -0
- data/README.md +13 -363
- data/lib/librarian/chef/version.rb +5 -0
- data/lib/librarian/cli.rb +1 -0
- data/lib/librarian/environment.rb +8 -2
- data/lib/librarian/mock/environment.rb +6 -1
- data/lib/librarian/mock/version.rb +5 -0
- data/lib/librarian/rspec/support/cli_macro.rb +120 -0
- data/lib/librarian/source/git.rb +1 -1
- data/lib/librarian/source/git/repository.rb +10 -2
- data/lib/librarian/version.rb +1 -1
- data/librarian.gemspec +15 -22
- data/spec/functional/cli_spec.rb +27 -0
- data/spec/functional/source/git/repository_spec.rb +2 -0
- metadata +69 -100
- data/lib/librarian/chef.rb +0 -1
- data/lib/librarian/chef/cli.rb +0 -47
- data/lib/librarian/chef/dsl.rb +0 -16
- data/lib/librarian/chef/environment.rb +0 -27
- data/lib/librarian/chef/extension.rb +0 -9
- data/lib/librarian/chef/integration/knife.rb +0 -46
- data/lib/librarian/chef/manifest_reader.rb +0 -59
- data/lib/librarian/chef/source.rb +0 -4
- data/lib/librarian/chef/source/git.rb +0 -25
- data/lib/librarian/chef/source/github.rb +0 -27
- data/lib/librarian/chef/source/local.rb +0 -69
- data/lib/librarian/chef/source/path.rb +0 -12
- data/lib/librarian/chef/source/site.rb +0 -442
- data/lib/librarian/chef/templates/Cheffile +0 -15
- data/spec/functional/chef/cli_spec.rb +0 -194
- data/spec/functional/chef/source/site_spec.rb +0 -266
- data/spec/integration/chef/source/git_spec.rb +0 -441
- data/spec/integration/chef/source/site_spec.rb +0 -217
- data/spec/support/cli_macro.rb +0 -114
@@ -1,441 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'securerandom'
|
3
|
-
|
4
|
-
require 'librarian'
|
5
|
-
require 'librarian/helpers'
|
6
|
-
require 'librarian/error'
|
7
|
-
require 'librarian/action/resolve'
|
8
|
-
require 'librarian/action/install'
|
9
|
-
require 'librarian/action/update'
|
10
|
-
require 'librarian/chef'
|
11
|
-
|
12
|
-
module Librarian
|
13
|
-
module Chef
|
14
|
-
module Source
|
15
|
-
describe Git do
|
16
|
-
|
17
|
-
let(:project_path) do
|
18
|
-
project_path = Pathname.new(__FILE__).expand_path
|
19
|
-
project_path = project_path.dirname until project_path.join("Rakefile").exist?
|
20
|
-
project_path
|
21
|
-
end
|
22
|
-
let(:tmp_path) { project_path.join("tmp/spec/integration/chef/source/git") }
|
23
|
-
after { tmp_path.rmtree if tmp_path && tmp_path.exist? }
|
24
|
-
|
25
|
-
let(:cookbooks_path) { tmp_path.join("cookbooks") }
|
26
|
-
|
27
|
-
# depends on repo_path being defined in each context
|
28
|
-
let(:env) { Environment.new(:project_path => repo_path) }
|
29
|
-
|
30
|
-
context "a single dependency with a git source" do
|
31
|
-
|
32
|
-
let(:sample_path) { tmp_path.join("sample") }
|
33
|
-
let(:sample_metadata) do
|
34
|
-
Helpers.strip_heredoc(<<-METADATA)
|
35
|
-
version "0.6.5"
|
36
|
-
METADATA
|
37
|
-
end
|
38
|
-
|
39
|
-
let(:first_sample_path) { cookbooks_path.join("first-sample") }
|
40
|
-
let(:first_sample_metadata) do
|
41
|
-
Helpers.strip_heredoc(<<-METADATA)
|
42
|
-
version "3.2.1"
|
43
|
-
METADATA
|
44
|
-
end
|
45
|
-
|
46
|
-
let(:second_sample_path) { cookbooks_path.join("second-sample") }
|
47
|
-
let(:second_sample_metadata) do
|
48
|
-
Helpers.strip_heredoc(<<-METADATA)
|
49
|
-
version "4.3.2"
|
50
|
-
METADATA
|
51
|
-
end
|
52
|
-
|
53
|
-
before do
|
54
|
-
sample_path.rmtree if sample_path.exist?
|
55
|
-
sample_path.mkpath
|
56
|
-
sample_path.join("metadata.rb").open("wb") { |f| f.write(sample_metadata) }
|
57
|
-
Dir.chdir(sample_path) do
|
58
|
-
`git init`
|
59
|
-
`git add metadata.rb`
|
60
|
-
`git commit -m "Initial commit."`
|
61
|
-
end
|
62
|
-
|
63
|
-
cookbooks_path.rmtree if cookbooks_path.exist?
|
64
|
-
cookbooks_path.mkpath
|
65
|
-
first_sample_path.mkpath
|
66
|
-
first_sample_path.join("metadata.rb").open("wb") { |f| f.write(first_sample_metadata) }
|
67
|
-
second_sample_path.mkpath
|
68
|
-
second_sample_path.join("metadata.rb").open("wb") { |f| f.write(second_sample_metadata) }
|
69
|
-
Dir.chdir(cookbooks_path) do
|
70
|
-
`git init`
|
71
|
-
`git add .`
|
72
|
-
`git commit -m "Initial commit."`
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "resolving" do
|
77
|
-
let(:repo_path) { tmp_path.join("repo/resolve") }
|
78
|
-
before do
|
79
|
-
repo_path.rmtree if repo_path.exist?
|
80
|
-
repo_path.mkpath
|
81
|
-
repo_path.join("cookbooks").mkpath
|
82
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
83
|
-
#!/usr/bin/env ruby
|
84
|
-
cookbook "sample", :git => #{sample_path.to_s.inspect}
|
85
|
-
CHEFFILE
|
86
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
87
|
-
end
|
88
|
-
|
89
|
-
context "the resolve" do
|
90
|
-
it "should not raise an exception" do
|
91
|
-
expect { Action::Resolve.new(env).run }.to_not raise_error
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context "the results" do
|
96
|
-
before { Action::Resolve.new(env).run }
|
97
|
-
|
98
|
-
it "should create the lockfile" do
|
99
|
-
repo_path.join("Cheffile.lock").should exist
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should not attempt to install the sample cookbok" do
|
103
|
-
repo_path.join("cookbooks/sample").should_not exist
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context "installing" do
|
109
|
-
let(:repo_path) { tmp_path.join("repo/install") }
|
110
|
-
before do
|
111
|
-
repo_path.rmtree if repo_path.exist?
|
112
|
-
repo_path.mkpath
|
113
|
-
repo_path.join("cookbooks").mkpath
|
114
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
115
|
-
#!/usr/bin/env ruby
|
116
|
-
cookbook "sample", :git => #{sample_path.to_s.inspect}
|
117
|
-
CHEFFILE
|
118
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
119
|
-
|
120
|
-
Action::Resolve.new(env).run
|
121
|
-
end
|
122
|
-
|
123
|
-
context "the install" do
|
124
|
-
it "should not raise an exception" do
|
125
|
-
expect { Action::Install.new(env).run }.to_not raise_error
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context "the results" do
|
130
|
-
before { Action::Install.new(env).run }
|
131
|
-
|
132
|
-
it "should create the lockfile" do
|
133
|
-
repo_path.join("Cheffile.lock").should exist
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should create the directory for the cookbook" do
|
137
|
-
repo_path.join("cookbooks/sample").should exist
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should copy the cookbook files into the cookbook directory" do
|
141
|
-
repo_path.join("cookbooks/sample/metadata.rb").should exist
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
context "resolving and and separately installing" do
|
147
|
-
let(:repo_path) { tmp_path.join("repo/resolve-install") }
|
148
|
-
before do
|
149
|
-
repo_path.rmtree if repo_path.exist?
|
150
|
-
repo_path.mkpath
|
151
|
-
repo_path.join("cookbooks").mkpath
|
152
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
153
|
-
#!/usr/bin/env ruby
|
154
|
-
cookbook "sample", :git => #{sample_path.to_s.inspect}
|
155
|
-
CHEFFILE
|
156
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
157
|
-
|
158
|
-
Action::Resolve.new(env).run
|
159
|
-
repo_path.join("tmp").rmtree if repo_path.join("tmp").exist?
|
160
|
-
end
|
161
|
-
|
162
|
-
context "the install" do
|
163
|
-
it "should not raise an exception" do
|
164
|
-
expect { Action::Install.new(env).run }.to_not raise_error
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
context "the results" do
|
169
|
-
before { Action::Install.new(env).run }
|
170
|
-
|
171
|
-
it "should create the directory for the cookbook" do
|
172
|
-
repo_path.join("cookbooks/sample").should exist
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should copy the cookbook files into the cookbook directory" do
|
176
|
-
repo_path.join("cookbooks/sample/metadata.rb").should exist
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
context "resolving, changing, and resolving" do
|
182
|
-
let(:repo_path) { tmp_path.join("repo/resolve-update") }
|
183
|
-
before do
|
184
|
-
repo_path.rmtree if repo_path.exist?
|
185
|
-
repo_path.mkpath
|
186
|
-
repo_path.join("cookbooks").mkpath
|
187
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
188
|
-
git #{cookbooks_path.to_s.inspect}
|
189
|
-
cookbook "first-sample"
|
190
|
-
CHEFFILE
|
191
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
192
|
-
Action::Resolve.new(env).run
|
193
|
-
|
194
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
195
|
-
git #{cookbooks_path.to_s.inspect}
|
196
|
-
cookbook "first-sample"
|
197
|
-
cookbook "second-sample"
|
198
|
-
CHEFFILE
|
199
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
200
|
-
end
|
201
|
-
|
202
|
-
context "the second resolve" do
|
203
|
-
it "should not raise an exception" do
|
204
|
-
expect { Action::Resolve.new(env).run }.to_not raise_error
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
end
|
210
|
-
|
211
|
-
context "with a path" do
|
212
|
-
|
213
|
-
let(:git_path) { tmp_path.join("big-git-repo") }
|
214
|
-
let(:sample_path) { git_path.join("buttercup") }
|
215
|
-
let(:sample_metadata) do
|
216
|
-
Helpers.strip_heredoc(<<-METADATA)
|
217
|
-
version "0.6.5"
|
218
|
-
METADATA
|
219
|
-
end
|
220
|
-
|
221
|
-
before do
|
222
|
-
git_path.rmtree if git_path.exist?
|
223
|
-
git_path.mkpath
|
224
|
-
sample_path.mkpath
|
225
|
-
sample_path.join("metadata.rb").open("wb") { |f| f.write(sample_metadata) }
|
226
|
-
Dir.chdir(git_path) do
|
227
|
-
`git init`
|
228
|
-
`git add .`
|
229
|
-
`git commit -m "Initial commit."`
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
context "if no path option is given" do
|
234
|
-
let(:repo_path) { tmp_path.join("repo/resolve") }
|
235
|
-
before do
|
236
|
-
repo_path.rmtree if repo_path.exist?
|
237
|
-
repo_path.mkpath
|
238
|
-
repo_path.join("cookbooks").mkpath
|
239
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
240
|
-
#!/usr/bin/env ruby
|
241
|
-
cookbook "sample",
|
242
|
-
:git => #{git_path.to_s.inspect}
|
243
|
-
CHEFFILE
|
244
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should not resolve" do
|
248
|
-
expect{ Action::Resolve.new(env).run }.to raise_error
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
context "if the path option is wrong" do
|
253
|
-
let(:repo_path) { tmp_path.join("repo/resolve") }
|
254
|
-
before do
|
255
|
-
repo_path.rmtree if repo_path.exist?
|
256
|
-
repo_path.mkpath
|
257
|
-
repo_path.join("cookbooks").mkpath
|
258
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
259
|
-
#!/usr/bin/env ruby
|
260
|
-
cookbook "sample",
|
261
|
-
:git => #{git_path.to_s.inspect},
|
262
|
-
:path => "jelly"
|
263
|
-
CHEFFILE
|
264
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
265
|
-
end
|
266
|
-
|
267
|
-
it "should not resolve" do
|
268
|
-
expect{ Action::Resolve.new(env).run }.to raise_error
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
context "if the path option is right" do
|
273
|
-
let(:repo_path) { tmp_path.join("repo/resolve") }
|
274
|
-
before do
|
275
|
-
repo_path.rmtree if repo_path.exist?
|
276
|
-
repo_path.mkpath
|
277
|
-
repo_path.join("cookbooks").mkpath
|
278
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
279
|
-
#!/usr/bin/env ruby
|
280
|
-
cookbook "sample",
|
281
|
-
:git => #{git_path.to_s.inspect},
|
282
|
-
:path => "buttercup"
|
283
|
-
CHEFFILE
|
284
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
285
|
-
end
|
286
|
-
|
287
|
-
context "the resolve" do
|
288
|
-
it "should not raise an exception" do
|
289
|
-
expect { Action::Resolve.new(env).run }.to_not raise_error
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
context "the results" do
|
294
|
-
before { Action::Resolve.new(env).run }
|
295
|
-
|
296
|
-
it "should create the lockfile" do
|
297
|
-
repo_path.join("Cheffile.lock").should exist
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
end
|
303
|
-
|
304
|
-
context "missing a metadata" do
|
305
|
-
let(:git_path) { tmp_path.join("big-git-repo") }
|
306
|
-
let(:repo_path) { tmp_path.join("repo/resolve") }
|
307
|
-
before do
|
308
|
-
git_path.rmtree if git_path.exist?
|
309
|
-
git_path.mkpath
|
310
|
-
Dir.chdir(git_path) do
|
311
|
-
`git init`
|
312
|
-
`touch not-a-metadata`
|
313
|
-
`git add .`
|
314
|
-
`git commit -m "Initial commit."`
|
315
|
-
end
|
316
|
-
repo_path.rmtree if repo_path.exist?
|
317
|
-
repo_path.mkpath
|
318
|
-
repo_path.join("cookbooks").mkpath
|
319
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
320
|
-
cookbook "sample",
|
321
|
-
:git => #{git_path.to_s.inspect}
|
322
|
-
CHEFFILE
|
323
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
324
|
-
end
|
325
|
-
|
326
|
-
context "the resolve" do
|
327
|
-
it "should raise an exception" do
|
328
|
-
expect { Action::Resolve.new(env).run }.to raise_error
|
329
|
-
end
|
330
|
-
|
331
|
-
it "should explain the problem" do
|
332
|
-
expect { Action::Resolve.new(env).run }.
|
333
|
-
to raise_error(Error, /no metadata file found/i)
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
context "the results" do
|
338
|
-
before { Action::Resolve.new(env).run rescue nil }
|
339
|
-
|
340
|
-
it "should not create the lockfile" do
|
341
|
-
repo_path.join("Cheffile.lock").should_not exist
|
342
|
-
end
|
343
|
-
|
344
|
-
it "should not create the directory for the cookbook" do
|
345
|
-
repo_path.join("cookbooks/sample").should_not exist
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
context "when upstream updates" do
|
351
|
-
let(:git_path) { tmp_path.join("upstream-updates-repo") }
|
352
|
-
let(:repo_path) { tmp_path.join("repo/resolve-with-upstream-updates") }
|
353
|
-
|
354
|
-
let(:sample_metadata) do
|
355
|
-
Helpers.strip_heredoc(<<-METADATA)
|
356
|
-
version "0.6.5"
|
357
|
-
METADATA
|
358
|
-
end
|
359
|
-
before do
|
360
|
-
|
361
|
-
# set up the git repo as normal, but let's also set up a release-stable branch
|
362
|
-
# from which our Cheffile will only pull stable releases
|
363
|
-
git_path.rmtree if git_path.exist?
|
364
|
-
git_path.mkpath
|
365
|
-
git_path.join("metadata.rb").open("w+b"){|f| f.write(sample_metadata)}
|
366
|
-
|
367
|
-
Dir.chdir(git_path) do
|
368
|
-
`git init`
|
369
|
-
`git add metadata.rb`
|
370
|
-
`git commit -m "Initial Commit."`
|
371
|
-
`git checkout -b some-branch --quiet`
|
372
|
-
`echo 'hi' > some-file`
|
373
|
-
`git add some-file`
|
374
|
-
`git commit -m 'Some File.'`
|
375
|
-
`git checkout master --quiet`
|
376
|
-
end
|
377
|
-
|
378
|
-
# set up the chef repo as normal, except the Cheffile points to the release-stable
|
379
|
-
# branch - we expect when the upstream copy of that branch is changed, then we can
|
380
|
-
# fetch & merge those changes when we update
|
381
|
-
repo_path.rmtree if repo_path.exist?
|
382
|
-
repo_path.mkpath
|
383
|
-
repo_path.join("cookbooks").mkpath
|
384
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
385
|
-
cookbook "sample",
|
386
|
-
:git => #{git_path.to_s.inspect},
|
387
|
-
:ref => "some-branch"
|
388
|
-
CHEFFILE
|
389
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
390
|
-
Action::Resolve.new(env).run
|
391
|
-
|
392
|
-
# change the upstream copy of that branch: we expect to be able to pull the latest
|
393
|
-
# when we re-resolve
|
394
|
-
Dir.chdir(git_path) do
|
395
|
-
`git checkout some-branch --quiet`
|
396
|
-
`echo 'ho' > some-other-file`
|
397
|
-
`git add some-other-file`
|
398
|
-
`git commit -m 'Some Other File.'`
|
399
|
-
`git checkout master --quiet`
|
400
|
-
end
|
401
|
-
end
|
402
|
-
|
403
|
-
let(:metadata_file) { repo_path.join("cookbooks/sample/metadata.rb") }
|
404
|
-
let(:old_code_file) { repo_path.join("cookbooks/sample/some-file") }
|
405
|
-
let(:new_code_file) { repo_path.join("cookbooks/sample/some-other-file") }
|
406
|
-
|
407
|
-
context "when updating not a cookbook from that source" do
|
408
|
-
before do
|
409
|
-
Action::Update.new(env).run
|
410
|
-
end
|
411
|
-
|
412
|
-
it "should pull the tip from upstream" do
|
413
|
-
Action::Install.new(env).run
|
414
|
-
|
415
|
-
metadata_file.should exist #sanity
|
416
|
-
old_code_file.should exist #sanity
|
417
|
-
|
418
|
-
new_code_file.should_not exist # the assertion
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
context "when updating a cookbook from that source" do
|
423
|
-
before do
|
424
|
-
Action::Update.new(env, :names => %w(sample)).run
|
425
|
-
end
|
426
|
-
|
427
|
-
it "should pull the tip from upstream" do
|
428
|
-
Action::Install.new(env).run
|
429
|
-
|
430
|
-
metadata_file.should exist #sanity
|
431
|
-
old_code_file.should exist #sanity
|
432
|
-
|
433
|
-
new_code_file.should exist # the assertion
|
434
|
-
end
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
end
|
439
|
-
end
|
440
|
-
end
|
441
|
-
end
|
@@ -1,217 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'json'
|
3
|
-
require 'webmock'
|
4
|
-
|
5
|
-
require 'librarian'
|
6
|
-
require 'librarian/helpers'
|
7
|
-
require 'librarian/action/resolve'
|
8
|
-
require 'librarian/action/install'
|
9
|
-
require 'librarian/chef'
|
10
|
-
|
11
|
-
module Librarian
|
12
|
-
module Chef
|
13
|
-
module Source
|
14
|
-
describe Site do
|
15
|
-
|
16
|
-
include WebMock::API
|
17
|
-
|
18
|
-
let(:project_path) do
|
19
|
-
project_path = Pathname.new(__FILE__).expand_path
|
20
|
-
project_path = project_path.dirname until project_path.join("Rakefile").exist?
|
21
|
-
project_path
|
22
|
-
end
|
23
|
-
let(:tmp_path) { project_path.join("tmp/spec/integration/chef/source/site") }
|
24
|
-
after { tmp_path.rmtree if tmp_path && tmp_path.exist? }
|
25
|
-
let(:sample_path) { tmp_path.join("sample") }
|
26
|
-
let(:sample_metadata) do
|
27
|
-
Helpers.strip_heredoc(<<-METADATA)
|
28
|
-
version "0.6.5"
|
29
|
-
METADATA
|
30
|
-
end
|
31
|
-
|
32
|
-
let(:api_url) { "http://site.cookbooks.com" }
|
33
|
-
|
34
|
-
let(:sample_index_data) do
|
35
|
-
{
|
36
|
-
"name" => "sample",
|
37
|
-
"versions" => [
|
38
|
-
"#{api_url}/cookbooks/sample/versions/0_6_5"
|
39
|
-
]
|
40
|
-
}
|
41
|
-
end
|
42
|
-
let(:sample_0_6_5_data) do
|
43
|
-
{
|
44
|
-
"version" => "0.6.5",
|
45
|
-
"file" => "#{api_url}/cookbooks/sample/versions/0_6_5/file.tar.gz"
|
46
|
-
}
|
47
|
-
end
|
48
|
-
let(:sample_0_6_5_package) do
|
49
|
-
s = StringIO.new
|
50
|
-
z = Zlib::GzipWriter.new(s, Zlib::NO_COMPRESSION)
|
51
|
-
t = Archive::Tar::Minitar::Output.new(z)
|
52
|
-
t.tar.add_file_simple("sample/metadata.rb", :mode => 0700,
|
53
|
-
:size => sample_metadata.bytesize){|io| io.write(sample_metadata)}
|
54
|
-
t.close
|
55
|
-
z.close unless z.closed?
|
56
|
-
s.string
|
57
|
-
end
|
58
|
-
|
59
|
-
# depends on repo_path being defined in each context
|
60
|
-
let(:env) { Environment.new(:project_path => repo_path) }
|
61
|
-
|
62
|
-
before do
|
63
|
-
stub_request(:get, "#{api_url}/cookbooks/sample").
|
64
|
-
to_return(:body => JSON.dump(sample_index_data))
|
65
|
-
|
66
|
-
stub_request(:get, "#{api_url}/cookbooks/sample/versions/0_6_5").
|
67
|
-
to_return(:body => JSON.dump(sample_0_6_5_data))
|
68
|
-
|
69
|
-
stub_request(:get, "#{api_url}/cookbooks/sample/versions/0_6_5/file.tar.gz").
|
70
|
-
to_return(:body => sample_0_6_5_package)
|
71
|
-
end
|
72
|
-
|
73
|
-
after do
|
74
|
-
WebMock.reset!
|
75
|
-
end
|
76
|
-
|
77
|
-
context "a single dependency with a site source" do
|
78
|
-
|
79
|
-
context "resolving" do
|
80
|
-
let(:repo_path) { tmp_path.join("repo/resolve") }
|
81
|
-
before do
|
82
|
-
repo_path.rmtree if repo_path.exist?
|
83
|
-
repo_path.mkpath
|
84
|
-
repo_path.join("cookbooks").mkpath
|
85
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
86
|
-
#!/usr/bin/env ruby
|
87
|
-
cookbook "sample", :site => #{api_url.inspect}
|
88
|
-
CHEFFILE
|
89
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
90
|
-
end
|
91
|
-
|
92
|
-
context "the resolve" do
|
93
|
-
it "should not raise an exception" do
|
94
|
-
expect { Action::Resolve.new(env).run }.to_not raise_error
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context "the results" do
|
99
|
-
before { Action::Resolve.new(env).run }
|
100
|
-
|
101
|
-
it "should create the lockfile" do
|
102
|
-
repo_path.join("Cheffile.lock").should exist
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should not attempt to install the cookbok" do
|
106
|
-
repo_path.join("cookbooks/sample").should_not exist
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
context "intalling" do
|
112
|
-
let(:repo_path) { tmp_path.join("repo/install") }
|
113
|
-
before do
|
114
|
-
repo_path.rmtree if repo_path.exist?
|
115
|
-
repo_path.mkpath
|
116
|
-
repo_path.join("cookbooks").mkpath
|
117
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
118
|
-
#!/usr/bin/env ruby
|
119
|
-
cookbook "sample", :site => #{api_url.inspect}
|
120
|
-
CHEFFILE
|
121
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
122
|
-
|
123
|
-
Action::Resolve.new(env).run
|
124
|
-
end
|
125
|
-
|
126
|
-
context "the install" do
|
127
|
-
it "should not raise an exception" do
|
128
|
-
expect { Action::Install.new(env).run }.to_not raise_error
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context "the results" do
|
133
|
-
before { Action::Install.new(env).run }
|
134
|
-
|
135
|
-
it "should create the lockfile" do
|
136
|
-
repo_path.join("Cheffile.lock").should exist
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should create a directory for the cookbook" do
|
140
|
-
repo_path.join("cookbooks/sample").should exist
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should copy the cookbook files into the cookbook directory" do
|
144
|
-
repo_path.join("cookbooks/sample/metadata.rb").should exist
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context "resolving and separately installing" do
|
150
|
-
let(:repo_path) { tmp_path.join("repo/resolve-install") }
|
151
|
-
before do
|
152
|
-
repo_path.rmtree if repo_path.exist?
|
153
|
-
repo_path.mkpath
|
154
|
-
repo_path.join("cookbooks").mkpath
|
155
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
156
|
-
#!/usr/bin/env ruby
|
157
|
-
cookbook "sample", :site => #{api_url.inspect}
|
158
|
-
CHEFFILE
|
159
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
160
|
-
|
161
|
-
Action::Resolve.new(env).run
|
162
|
-
repo_path.join("tmp").rmtree if repo_path.join("tmp").exist?
|
163
|
-
end
|
164
|
-
|
165
|
-
context "the install" do
|
166
|
-
it "should not raise an exception" do
|
167
|
-
expect { Action::Install.new(env).run }.to_not raise_error
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context "the results" do
|
172
|
-
before { Action::Install.new(env).run }
|
173
|
-
|
174
|
-
it "should create a directory for the cookbook" do
|
175
|
-
repo_path.join("cookbooks/sample").should exist
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should copy the cookbook files into the cookbook directory" do
|
179
|
-
repo_path.join("cookbooks/sample/metadata.rb").should exist
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
context "when the repo path has a space" do
|
187
|
-
|
188
|
-
let(:repo_path) { tmp_path.join("repo/with extra spaces/resolve") }
|
189
|
-
|
190
|
-
before do
|
191
|
-
repo_path.rmtree if repo_path.exist?
|
192
|
-
repo_path.mkpath
|
193
|
-
repo_path.join("cookbooks").mkpath
|
194
|
-
|
195
|
-
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
196
|
-
#!/usr/bin/env ruby
|
197
|
-
cookbook "sample", :site => #{api_url.inspect}
|
198
|
-
CHEFFILE
|
199
|
-
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
200
|
-
end
|
201
|
-
|
202
|
-
after do
|
203
|
-
repo_path.rmtree
|
204
|
-
end
|
205
|
-
|
206
|
-
context "the resolution" do
|
207
|
-
it "should not raise an exception" do
|
208
|
-
expect { Action::Resolve.new(env).run }.to_not raise_error
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
end
|
213
|
-
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|