knife-essentials 0.9.2 → 0.9.3
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/chef/knife/raw_essentials.rb +3 -61
- data/lib/chef_fs/data_handler/data_handler_base.rb +2 -1
- data/lib/chef_fs/file_system/base_fs_object.rb +75 -1
- data/lib/chef_fs/file_system/chef_repository_file_system_entry.rb +23 -0
- data/lib/chef_fs/file_system/cookbook_dir.rb +27 -13
- data/lib/chef_fs/file_system/cookbooks_dir.rb +89 -30
- data/lib/chef_fs/file_system/data_bags_dir.rb +5 -1
- data/lib/chef_fs/file_system/nodes_dir.rb +8 -14
- data/lib/chef_fs/file_system/rest_list_dir.rb +6 -2
- data/lib/chef_fs/file_system/rest_list_entry.rb +15 -3
- data/lib/chef_fs/knife.rb +28 -17
- data/lib/chef_fs/version.rb +1 -1
- data/spec/chef_fs/file_system/chef_server_root_dir_spec.rb +26 -12
- data/spec/chef_fs/file_system/cookbook_dir_spec.rb +582 -0
- data/spec/chef_fs/file_system/cookbooks_dir_spec.rb +81 -489
- data/spec/chef_fs/file_system/data_bags_dir_spec.rb +63 -49
- data/spec/integration/deps_spec.rb +32 -32
- data/spec/integration/diff_spec.rb +425 -133
- data/spec/integration/download_spec.rb +743 -211
- data/spec/integration/upload_spec.rb +814 -244
- data/spec/support/integration_helper.rb +33 -6
- data/spec/support/knife_support.rb +4 -2
- metadata +19 -2
@@ -30,544 +30,136 @@ describe ChefFS::FileSystem::CookbooksDir do
|
|
30
30
|
},
|
31
31
|
'everything')
|
32
32
|
}
|
33
|
-
|
34
|
-
let(:
|
35
|
-
@rest.should_receive(:get_rest).with('cookbooks').once.and_return(
|
33
|
+
|
34
|
+
let(:cookbook_response) do
|
36
35
|
{
|
37
|
-
"achild" =>
|
38
|
-
|
39
|
-
|
36
|
+
"achild" => {
|
37
|
+
"url" => "http://example.com/cookbooks/achild",
|
38
|
+
'versions' => [
|
39
|
+
{ "version" => '2.0.0', 'url' => 'http://example.com/cookbooks/achild/2.0.0' },
|
40
|
+
{ "version" => '1.0.0', 'url' => 'http://example.com/cookbooks/achild/2.0.0' }, ] },
|
41
|
+
"bchild" => {
|
42
|
+
"url" => "http://example.com/cookbokks/bchild",
|
43
|
+
'versions' => [ { "version" => '1.0.0', 'url' => 'http://example.com/cookbooks/achild/2.0.0' }, ] },
|
44
|
+
|
45
|
+
}
|
40
46
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
47
|
+
|
48
|
+
let(:cookbooks_dir) { root_dir.child('cookbooks') }
|
49
|
+
let(:api_url) { 'cookbooks' }
|
50
|
+
let(:should_list_cookbooks) { rest.should_receive(:get_rest).with(api_url).once.and_return(cookbook_response) }
|
51
|
+
|
52
|
+
let(:rest) { double 'rest' }
|
53
|
+
before(:each) { Chef::REST.stub(:new).with('url','username','key') { rest } }
|
54
|
+
|
55
|
+
def self.with_versioned_cookbooks
|
56
|
+
before(:each) { Chef::Config[:versioned_cookbooks] = true }
|
57
|
+
after(:each) { Chef::Config[:versioned_cookbooks] = false }
|
58
|
+
|
59
|
+
let(:api_url) { 'cookbooks/?num_versions=all' }
|
44
60
|
end
|
45
61
|
|
46
62
|
it 'has / as parent' do
|
47
63
|
cookbooks_dir.parent.should == root_dir
|
48
64
|
end
|
65
|
+
|
49
66
|
it 'is a directory' do
|
50
67
|
cookbooks_dir.dir?.should be_true
|
51
68
|
end
|
69
|
+
|
52
70
|
it 'exists' do
|
53
71
|
cookbooks_dir.exists?.should be_true
|
54
72
|
end
|
73
|
+
|
55
74
|
it 'has name cookbooks' do
|
56
75
|
cookbooks_dir.name.should == 'cookbooks'
|
57
76
|
end
|
77
|
+
|
58
78
|
it 'has path /cookbooks' do
|
59
79
|
cookbooks_dir.path.should == '/cookbooks'
|
60
80
|
end
|
81
|
+
|
61
82
|
it 'has path_for_printing remote/cookbooks' do
|
62
83
|
cookbooks_dir.path_for_printing.should == 'remote/cookbooks'
|
63
84
|
end
|
85
|
+
|
64
86
|
it 'has correct children' do
|
65
87
|
should_list_cookbooks
|
66
88
|
cookbooks_dir.children.map { |child| child.name }.should =~ %w(achild bchild)
|
67
89
|
end
|
68
|
-
it 'can have directories as children' do
|
69
|
-
cookbooks_dir.can_have_child?('blah', true).should be_true
|
70
|
-
end
|
71
|
-
it 'cannot have files as children' do
|
72
|
-
cookbooks_dir.can_have_child?('blah', false).should be_false
|
73
|
-
end
|
74
|
-
|
75
|
-
#
|
76
|
-
# Cookbook dir (/cookbooks/<blah>)
|
77
|
-
#
|
78
|
-
shared_examples_for 'a segment directory' do
|
79
|
-
it 'has cookbook as parent' do
|
80
|
-
segment_dir.parent.should == cookbook_dir
|
81
|
-
end
|
82
|
-
it 'exists' do
|
83
|
-
segment_dir.exists?.should be_true
|
84
|
-
end
|
85
|
-
it 'is a directory' do
|
86
|
-
segment_dir.dir?.should be_true
|
87
|
-
end
|
88
|
-
it 'name is correct' do
|
89
|
-
segment_dir.name.should == segment_dir_name
|
90
|
-
end
|
91
|
-
it 'path is correct' do
|
92
|
-
segment_dir.path.should == "/cookbooks/#{cookbook_dir_name}/#{segment_dir_name}"
|
93
|
-
end
|
94
|
-
it 'path_for_printing is correct' do
|
95
|
-
segment_dir.path_for_printing.should == "remote/cookbooks/#{cookbook_dir_name}/#{segment_dir_name}"
|
96
|
-
end
|
97
|
-
it 'has the right children' do
|
98
|
-
segment_dir.children =~ %w(a.rb b.txt subdir)
|
99
|
-
end
|
100
|
-
it 'children are identical to child()' do
|
101
|
-
segment_dir.child('a.rb').should == segment_dir.children.select { |child| child.name == 'a.rb' }.first
|
102
|
-
segment_dir.child('b.txt').should == segment_dir.children.select { |child| child.name == 'b.txt' }.first
|
103
|
-
segment_dir.child('subdir').should == segment_dir.children.select { |child| child.name == 'subdir' }.first
|
104
|
-
end
|
105
|
-
context 'subdirectory' do
|
106
|
-
it 'has segment as a parent' do
|
107
|
-
segment_dir.child('subdir').parent.should == segment_dir
|
108
|
-
end
|
109
|
-
it 'exists' do
|
110
|
-
segment_dir.child('subdir').exists?.should be_true
|
111
|
-
end
|
112
|
-
it 'is a directory' do
|
113
|
-
segment_dir.child('subdir').dir?.should be_true
|
114
|
-
end
|
115
|
-
it 'name is subdir' do
|
116
|
-
segment_dir.child('subdir').name.should == 'subdir'
|
117
|
-
end
|
118
|
-
it 'path is correct' do
|
119
|
-
segment_dir.child('subdir').path.should == "/cookbooks/#{cookbook_dir_name}/#{segment_dir_name}/subdir"
|
120
|
-
end
|
121
|
-
it 'path_for_printing is correct' do
|
122
|
-
segment_dir.child('subdir').path_for_printing.should == "remote/cookbooks/#{cookbook_dir_name}/#{segment_dir_name}/subdir"
|
123
|
-
end
|
124
|
-
it 'has the right children' do
|
125
|
-
segment_dir.child('subdir').children =~ %w(a.rb b.txt)
|
126
|
-
end
|
127
|
-
it 'children are identical to child()' do
|
128
|
-
segment_dir.child('subdir').child('a.rb').should == segment_dir.child('subdir').children.select { |child| child.name == 'a.rb' }.first
|
129
|
-
segment_dir.child('subdir').child('b.txt').should == segment_dir.child('subdir').children.select { |child| child.name == 'b.txt' }.first
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
shared_examples_for 'a cookbook' do
|
135
|
-
it 'has cookbooks as parent' do
|
136
|
-
cookbook_dir.parent == cookbooks_dir
|
137
|
-
end
|
138
|
-
it 'is a directory' do
|
139
|
-
should_list_cookbooks
|
140
|
-
cookbook_dir.dir?.should be_true
|
141
|
-
end
|
142
|
-
it 'exists' do
|
143
|
-
should_list_cookbooks
|
144
|
-
cookbook_dir.exists?.should be_true
|
145
|
-
end
|
146
|
-
it 'has name <cookbook name>' do
|
147
|
-
cookbook_dir.name.should == cookbook_dir_name
|
148
|
-
end
|
149
|
-
it 'has path /cookbooks/<cookbook name>' do
|
150
|
-
cookbook_dir.path.should == "/cookbooks/#{cookbook_dir_name}"
|
151
|
-
end
|
152
|
-
it 'has path_for_printing remote/cookbooks/<cookbook name>' do
|
153
|
-
cookbook_dir.path_for_printing.should == "remote/cookbooks/#{cookbook_dir_name}"
|
154
|
-
end
|
155
|
-
it 'can have segment directories as children' do
|
156
|
-
cookbook_dir.can_have_child?('attributes', true).should be_true
|
157
|
-
cookbook_dir.can_have_child?('definitions', true).should be_true
|
158
|
-
cookbook_dir.can_have_child?('recipes', true).should be_true
|
159
|
-
cookbook_dir.can_have_child?('libraries', true).should be_true
|
160
|
-
cookbook_dir.can_have_child?('templates', true).should be_true
|
161
|
-
cookbook_dir.can_have_child?('files', true).should be_true
|
162
|
-
cookbook_dir.can_have_child?('resources', true).should be_true
|
163
|
-
cookbook_dir.can_have_child?('providers', true).should be_true
|
164
|
-
end
|
165
|
-
it 'cannot have arbitrary directories as children' do
|
166
|
-
cookbook_dir.can_have_child?('blah', true).should be_false
|
167
|
-
cookbook_dir.can_have_child?('root_files', true).should be_false
|
168
|
-
end
|
169
|
-
it 'can have files as children' do
|
170
|
-
cookbook_dir.can_have_child?('blah', false).should be_true
|
171
|
-
cookbook_dir.can_have_child?('root_files', false).should be_true
|
172
|
-
cookbook_dir.can_have_child?('attributes', false).should be_true
|
173
|
-
cookbook_dir.can_have_child?('definitions', false).should be_true
|
174
|
-
cookbook_dir.can_have_child?('recipes', false).should be_true
|
175
|
-
cookbook_dir.can_have_child?('libraries', false).should be_true
|
176
|
-
cookbook_dir.can_have_child?('templates', false).should be_true
|
177
|
-
cookbook_dir.can_have_child?('files', false).should be_true
|
178
|
-
cookbook_dir.can_have_child?('resources', false).should be_true
|
179
|
-
cookbook_dir.can_have_child?('providers', false).should be_true
|
180
|
-
end
|
181
|
-
# TODO test empty parts, cross-contamination (root_files named templates/x.txt, libraries named recipes/blah.txt)
|
182
|
-
context 'with a full directory structure' do
|
183
|
-
def json_file(path, checksum)
|
184
|
-
filename = ChefFS::PathUtils.split(path)[-1]
|
185
|
-
{
|
186
|
-
:name => filename,
|
187
|
-
:url => "cookbook_file:#{path}",
|
188
|
-
:checksum => checksum,
|
189
|
-
:path => path,
|
190
|
-
:specificity => "default"
|
191
|
-
}
|
192
|
-
end
|
193
|
-
def json_files(cookbook_dir)
|
194
|
-
result = []
|
195
|
-
files.each do |filename|
|
196
|
-
if filename =~ /^#{cookbook_dir}\//
|
197
|
-
result << json_file(filename, file_checksums[filename])
|
198
|
-
end
|
199
|
-
end
|
200
|
-
result
|
201
|
-
end
|
202
|
-
let(:files) {
|
203
|
-
result = []
|
204
|
-
%w(attributes definitions files libraries providers recipes resources templates).each do |segment|
|
205
|
-
result << "#{segment}/a.rb"
|
206
|
-
result << "#{segment}/b.txt"
|
207
|
-
result << "#{segment}/subdir/a.rb"
|
208
|
-
result << "#{segment}/subdir/b.txt"
|
209
|
-
end
|
210
|
-
result << 'a.rb'
|
211
|
-
result << 'b.txt'
|
212
|
-
result << 'subdir/a.rb'
|
213
|
-
result << 'subdir/b.txt'
|
214
|
-
result << 'root_files'
|
215
|
-
result
|
216
|
-
}
|
217
|
-
let(:file_checksums) {
|
218
|
-
result = {}
|
219
|
-
files.each_with_index do |file, i|
|
220
|
-
result[file] = i.to_s(16)
|
221
|
-
end
|
222
|
-
result
|
223
|
-
}
|
224
|
-
let(:should_get_cookbook) do
|
225
|
-
cookbook = double('cookbook')
|
226
|
-
cookbook.should_receive(:manifest).and_return({
|
227
|
-
:attributes => json_files('attributes'),
|
228
|
-
:definitions => json_files('definitions'),
|
229
|
-
:files => json_files('files'),
|
230
|
-
:libraries => json_files('libraries'),
|
231
|
-
:providers => json_files('providers'),
|
232
|
-
:recipes => json_files('recipes'),
|
233
|
-
:resources => json_files('resources'),
|
234
|
-
:templates => json_files('templates'),
|
235
|
-
:root_files => [
|
236
|
-
json_file('a.rb', file_checksums['a.rb']),
|
237
|
-
json_file('b.txt', file_checksums['b.txt']),
|
238
|
-
json_file('subdir/a.rb', file_checksums['subdir/a.rb']),
|
239
|
-
json_file('subdir/b.txt', file_checksums['subdir/b.txt']),
|
240
|
-
json_file('root_files', file_checksums['root_files'])
|
241
|
-
]
|
242
|
-
})
|
243
|
-
@rest.should_receive(:get_rest).with("cookbooks/#{cookbook_dir_name}/_latest").once.and_return(cookbook)
|
244
|
-
end
|
245
90
|
|
246
|
-
|
247
|
-
|
248
|
-
cookbook_dir.children.map { |child| child.name }.should =~ %w(attributes definitions files libraries providers recipes resources templates a.rb b.txt subdir root_files)
|
249
|
-
end
|
250
|
-
it 'children and child() yield the exact same objects' do
|
251
|
-
should_get_cookbook
|
252
|
-
cookbook_dir.children.each { |child| child.should == cookbook_dir.child(child.name) }
|
253
|
-
end
|
254
|
-
it 'all files exist (recursive) and have correct parent, path, path_for_printing, checksum and type' do
|
255
|
-
should_get_cookbook
|
256
|
-
file_checksums.each do |path, checksum|
|
257
|
-
file = ChefFS::FileSystem.resolve_path(cookbook_dir, path)
|
258
|
-
file_parts = path.split('/')
|
259
|
-
if file_parts.length == 3
|
260
|
-
file.parent.parent.parent.should == cookbook_dir
|
261
|
-
elsif file_parts.length == 2
|
262
|
-
file.parent.parent.should == cookbook_dir
|
263
|
-
else
|
264
|
-
file.parent.should == cookbook_dir
|
265
|
-
end
|
266
|
-
file.exists?.should be_true
|
267
|
-
file.dir?.should be_false
|
268
|
-
file.name.should == file_parts[-1]
|
269
|
-
file.path.should == "/cookbooks/#{cookbook_dir_name}/#{path}"
|
270
|
-
file.path_for_printing.should == "remote/cookbooks/#{cookbook_dir_name}/#{path}"
|
271
|
-
file.checksum.should == checksum
|
272
|
-
end
|
273
|
-
end
|
274
|
-
it 'all files can be read' do
|
275
|
-
should_get_cookbook
|
276
|
-
files.each do |path|
|
277
|
-
cookbook_file = double(path)
|
278
|
-
cookbook_file.should_receive(:open).with(no_args()).once
|
279
|
-
cookbook_file.should_receive(:read).with(no_args()).once.and_return("This is #{path}'s content")
|
280
|
-
cookbook_file.should_receive(:close!).with(no_args()).once
|
281
|
-
@rest.should_receive(:get_rest).with("cookbook_file:#{path}", true).once.and_return(cookbook_file)
|
282
|
-
@rest.should_receive(:sign_on_redirect).with(no_args()).once.and_return(true)
|
283
|
-
@rest.should_receive(:sign_on_redirect=).with(false).once
|
284
|
-
@rest.should_receive(:sign_on_redirect=).with(true).once
|
285
|
-
file = ChefFS::FileSystem.resolve_path(cookbook_dir, path)
|
286
|
-
file.read.should == "This is #{path}'s content"
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
context 'the attributes segment' do
|
291
|
-
let(:segment_dir) { cookbook_dir.child('attributes') }
|
292
|
-
let(:segment_dir_name) { 'attributes' }
|
293
|
-
it_behaves_like 'a segment directory'
|
91
|
+
describe '#can_have_child?' do
|
92
|
+
subject { cookbooks_dir.can_have_child? cookbook_name, is_dir? }
|
294
93
|
|
295
|
-
|
296
|
-
|
297
|
-
end
|
94
|
+
let(:cookbook_name) { 'blah' }
|
95
|
+
let(:is_dir?) { true }
|
298
96
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
it 'cannot have non-ruby files' do
|
305
|
-
should_get_cookbook
|
306
|
-
segment_dir.can_have_child?('blah.txt', false).should be_false
|
307
|
-
segment_dir.can_have_child?('.blah.txt', false).should be_false
|
308
|
-
end
|
309
|
-
it 'cannot have subdirectories' do
|
310
|
-
should_get_cookbook
|
311
|
-
segment_dir.can_have_child?('blah', true).should be_false
|
312
|
-
end
|
313
|
-
end
|
97
|
+
# /cookbooks should contain only directories
|
98
|
+
context 'when child is a directory' do
|
99
|
+
let(:is_dir?) { true }
|
100
|
+
it { should be_true }
|
101
|
+
end
|
314
102
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
103
|
+
context 'when child is a file' do
|
104
|
+
let(:is_dir?) { false }
|
105
|
+
it { should be_false }
|
106
|
+
end
|
319
107
|
|
320
|
-
|
321
|
-
|
322
|
-
end
|
108
|
+
context 'with versioned cookbooks' do
|
109
|
+
with_versioned_cookbooks
|
323
110
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
end
|
328
|
-
it 'cannot have non-ruby files' do
|
329
|
-
segment_dir.can_have_child?('blah.txt', false).should be_false
|
330
|
-
segment_dir.can_have_child?('.blah.txt', false).should be_false
|
331
|
-
end
|
332
|
-
it 'cannot have subdirectories' do
|
333
|
-
segment_dir.can_have_child?('blah', true).should be_false
|
334
|
-
end
|
111
|
+
context 'when name conforms to <cookbook_name>-<verson>' do
|
112
|
+
let(:cookbook_name) { 'apt-1.8.4' }
|
113
|
+
it { should be_true }
|
335
114
|
end
|
336
115
|
|
337
|
-
context '
|
338
|
-
let(:
|
339
|
-
|
340
|
-
it_behaves_like 'a segment directory'
|
341
|
-
|
342
|
-
before(:each) do
|
343
|
-
should_get_cookbook
|
344
|
-
end
|
345
|
-
|
346
|
-
it 'can have ruby files' do
|
347
|
-
segment_dir.can_have_child?('blah.rb', false).should be_true
|
348
|
-
segment_dir.can_have_child?('.blah.rb', false).should be_true
|
349
|
-
end
|
350
|
-
it 'can have non-ruby files' do
|
351
|
-
segment_dir.can_have_child?('blah.txt', false).should be_true
|
352
|
-
segment_dir.can_have_child?('.blah.txt', false).should be_true
|
353
|
-
end
|
354
|
-
it 'can have subdirectories' do
|
355
|
-
segment_dir.can_have_child?('blah', true).should be_true
|
356
|
-
end
|
357
|
-
it 'subdirectories can have ruby files' do
|
358
|
-
segment_dir.child('subdir').can_have_child?('blah.rb', false).should be_true
|
359
|
-
segment_dir.child('subdir').can_have_child?('.blah.rb', false).should be_true
|
360
|
-
end
|
361
|
-
it 'subdirectories can have non-ruby files' do
|
362
|
-
segment_dir.child('subdir').can_have_child?('blah.txt', false).should be_true
|
363
|
-
segment_dir.child('subdir').can_have_child?('.blah.txt', false).should be_true
|
364
|
-
end
|
365
|
-
it 'subdirectories can have subdirectories' do
|
366
|
-
segment_dir.child('subdir').can_have_child?('blah', true).should be_true
|
367
|
-
end
|
116
|
+
context 'when name does not conform to <cookbook_name>-<version>' do
|
117
|
+
let(:cookbook_name) { 'apt' }
|
118
|
+
it { should be_false }
|
368
119
|
end
|
120
|
+
end
|
121
|
+
end
|
369
122
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
it_behaves_like 'a segment directory'
|
374
|
-
|
375
|
-
before(:each) do
|
376
|
-
should_get_cookbook
|
377
|
-
end
|
378
|
-
|
379
|
-
it 'can have ruby files' do
|
380
|
-
segment_dir.can_have_child?('blah.rb', false).should be_true
|
381
|
-
segment_dir.can_have_child?('.blah.rb', false).should be_true
|
382
|
-
end
|
383
|
-
it 'cannot have non-ruby files' do
|
384
|
-
segment_dir.can_have_child?('blah.txt', false).should be_false
|
385
|
-
segment_dir.can_have_child?('.blah.txt', false).should be_false
|
386
|
-
end
|
387
|
-
it 'cannot have subdirectories' do
|
388
|
-
segment_dir.can_have_child?('blah', true).should be_false
|
389
|
-
end
|
390
|
-
end
|
123
|
+
describe '#children' do
|
124
|
+
subject { cookbooks_dir.children }
|
125
|
+
before(:each) { should_list_cookbooks }
|
391
126
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
it_behaves_like 'a segment directory'
|
127
|
+
let(:entity_names) { subject.map(&:name) }
|
128
|
+
let(:cookbook_names) { subject.map(&:cookbook_name) }
|
129
|
+
let(:versions) { subject.map(&:version) }
|
396
130
|
|
397
|
-
|
398
|
-
|
399
|
-
end
|
131
|
+
context 'with versioned cookbooks' do
|
132
|
+
with_versioned_cookbooks
|
400
133
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
it 'cannot have non-ruby files' do
|
406
|
-
segment_dir.can_have_child?('blah.txt', false).should be_false
|
407
|
-
segment_dir.can_have_child?('.blah.txt', false).should be_false
|
408
|
-
end
|
409
|
-
it 'can have subdirectories' do
|
410
|
-
segment_dir.can_have_child?('blah', true).should be_true
|
411
|
-
end
|
412
|
-
it 'subdirectories can have ruby files' do
|
413
|
-
segment_dir.child('subdir').can_have_child?('blah.rb', false).should be_true
|
414
|
-
segment_dir.child('subdir').can_have_child?('.blah.rb', false).should be_true
|
415
|
-
end
|
416
|
-
it 'subdirectories cannot have non-ruby files' do
|
417
|
-
segment_dir.child('subdir').can_have_child?('blah.txt', false).should be_false
|
418
|
-
segment_dir.child('subdir').can_have_child?('.blah.txt', false).should be_false
|
419
|
-
end
|
420
|
-
it 'subdirectories can have subdirectories' do
|
421
|
-
segment_dir.child('subdir').can_have_child?('blah', true).should be_true
|
422
|
-
end
|
134
|
+
it 'should return all versions of cookbooks in <cookbook_name>-<version> format' do
|
135
|
+
entity_names.should include('achild-2.0.0')
|
136
|
+
entity_names.should include('achild-1.0.0')
|
137
|
+
entity_names.should include('bchild-1.0.0')
|
423
138
|
end
|
424
139
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
it_behaves_like 'a segment directory'
|
429
|
-
|
430
|
-
before(:each) do
|
431
|
-
should_get_cookbook
|
432
|
-
end
|
433
|
-
|
434
|
-
it 'can have ruby files' do
|
435
|
-
segment_dir.can_have_child?('blah.rb', false).should be_true
|
436
|
-
segment_dir.can_have_child?('.blah.rb', false).should be_true
|
437
|
-
end
|
438
|
-
it 'cannot have non-ruby files' do
|
439
|
-
segment_dir.can_have_child?('blah.txt', false).should be_false
|
440
|
-
segment_dir.can_have_child?('.blah.txt', false).should be_false
|
441
|
-
end
|
442
|
-
it 'cannot have subdirectories' do
|
443
|
-
segment_dir.can_have_child?('blah', true).should be_false
|
444
|
-
end
|
140
|
+
it 'should return cookbooks with server canonical cookbook name' do
|
141
|
+
cookbook_names.should include('achild')
|
142
|
+
cookbook_names.should include('bchild')
|
445
143
|
end
|
446
144
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
before(:each) do
|
453
|
-
should_get_cookbook
|
454
|
-
end
|
455
|
-
|
456
|
-
it 'can have ruby files' do
|
457
|
-
segment_dir.can_have_child?('blah.rb', false).should be_true
|
458
|
-
segment_dir.can_have_child?('.blah.rb', false).should be_true
|
459
|
-
end
|
460
|
-
it 'cannot have non-ruby files' do
|
461
|
-
segment_dir.can_have_child?('blah.txt', false).should be_false
|
462
|
-
segment_dir.can_have_child?('.blah.txt', false).should be_false
|
463
|
-
end
|
464
|
-
it 'can have subdirectories' do
|
465
|
-
segment_dir.can_have_child?('blah', true).should be_true
|
466
|
-
end
|
467
|
-
it 'subdirectories can have ruby files' do
|
468
|
-
segment_dir.child('subdir').can_have_child?('blah.rb', false).should be_true
|
469
|
-
segment_dir.child('subdir').can_have_child?('.blah.rb', false).should be_true
|
470
|
-
end
|
471
|
-
it 'subdirectories cannot have non-ruby files' do
|
472
|
-
segment_dir.child('subdir').can_have_child?('blah.txt', false).should be_false
|
473
|
-
segment_dir.child('subdir').can_have_child?('.blah.txt', false).should be_false
|
474
|
-
end
|
475
|
-
it 'subdirectories can have subdirectories' do
|
476
|
-
segment_dir.child('subdir').can_have_child?('blah', true).should be_true
|
477
|
-
end
|
145
|
+
it 'should return cookbooks with version numbers' do
|
146
|
+
versions.should include('2.0.0')
|
147
|
+
versions.should include('1.0.0')
|
148
|
+
versions.uniq.size.should eql 2
|
478
149
|
end
|
150
|
+
end
|
479
151
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
before(:each) do
|
486
|
-
should_get_cookbook
|
487
|
-
end
|
488
|
-
|
489
|
-
it 'can have ruby files' do
|
490
|
-
segment_dir.can_have_child?('blah.rb', false).should be_true
|
491
|
-
segment_dir.can_have_child?('.blah.rb', false).should be_true
|
492
|
-
end
|
493
|
-
it 'can have non-ruby files' do
|
494
|
-
segment_dir.can_have_child?('blah.txt', false).should be_true
|
495
|
-
segment_dir.can_have_child?('.blah.txt', false).should be_true
|
496
|
-
end
|
497
|
-
it 'can have subdirectories' do
|
498
|
-
segment_dir.can_have_child?('blah', true).should be_true
|
499
|
-
end
|
500
|
-
it 'subdirectories can have ruby files' do
|
501
|
-
segment_dir.child('subdir').can_have_child?('blah.rb', false).should be_true
|
502
|
-
segment_dir.child('subdir').can_have_child?('.blah.rb', false).should be_true
|
503
|
-
end
|
504
|
-
it 'subdirectories can have non-ruby files' do
|
505
|
-
segment_dir.child('subdir').can_have_child?('blah.txt', false).should be_true
|
506
|
-
segment_dir.child('subdir').can_have_child?('.blah.txt', false).should be_true
|
507
|
-
end
|
508
|
-
it 'subdirectories can have subdirectories' do
|
509
|
-
segment_dir.child('subdir').can_have_child?('blah', true).should be_true
|
510
|
-
end
|
152
|
+
context 'without versioned cookbooks' do
|
153
|
+
it 'should return a single version for each cookbook' do
|
154
|
+
entity_names.should include('achild')
|
155
|
+
entity_names.should include('bchild')
|
511
156
|
end
|
512
157
|
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
before(:each) do
|
517
|
-
should_get_cookbook
|
518
|
-
end
|
519
|
-
|
520
|
-
# Really, since these shouldn't exist in the first place,
|
521
|
-
# it doesn't matter; but these REALLY shouldn't be able to
|
522
|
-
# have any files in them at all.
|
523
|
-
it 'can have ruby files' do
|
524
|
-
root_subdir.can_have_child?('blah.rb', false).should be_true
|
525
|
-
root_subdir.can_have_child?('.blah.rb', false).should be_true
|
526
|
-
end
|
527
|
-
it 'can have non-ruby files' do
|
528
|
-
root_subdir.can_have_child?('blah.txt', false).should be_true
|
529
|
-
root_subdir.can_have_child?('.blah.txt', false).should be_true
|
530
|
-
end
|
531
|
-
it 'cannot have subdirectories' do
|
532
|
-
root_subdir.can_have_child?('blah', true).should be_false
|
533
|
-
end
|
158
|
+
it "should return nil for version numbers" do
|
159
|
+
versions.should == [ nil, nil ]
|
160
|
+
versions.uniq.size.should eql 1
|
534
161
|
end
|
535
162
|
end
|
536
163
|
end
|
537
164
|
|
538
|
-
context 'achild from cookbooks_dir.children' do
|
539
|
-
let(:cookbook_dir_name) { 'achild' }
|
540
|
-
let(:cookbook_dir) do
|
541
|
-
should_list_cookbooks
|
542
|
-
cookbooks_dir.children.select { |child| child.name == 'achild' }.first
|
543
|
-
end
|
544
|
-
it_behaves_like 'a cookbook'
|
545
|
-
end
|
546
|
-
context 'cookbooks_dir.child(achild)' do
|
547
|
-
let(:cookbook_dir_name) { 'achild' }
|
548
|
-
let(:cookbook_dir) { cookbooks_dir.child('achild') }
|
549
|
-
it_behaves_like 'a cookbook'
|
550
|
-
end
|
551
|
-
context 'nonexistent cookbooks_dir.child()' do
|
552
|
-
let(:nonexistent_child) { cookbooks_dir.child('blah') }
|
553
|
-
it 'has correct parent, name, path and path_for_printing' do
|
554
|
-
nonexistent_child.parent.should == cookbooks_dir
|
555
|
-
nonexistent_child.name.should == "blah"
|
556
|
-
nonexistent_child.path.should == "/cookbooks/blah"
|
557
|
-
nonexistent_child.path_for_printing.should == "remote/cookbooks/blah"
|
558
|
-
end
|
559
|
-
it 'does not exist' do
|
560
|
-
should_list_cookbooks
|
561
|
-
nonexistent_child.exists?.should be_false
|
562
|
-
end
|
563
|
-
it 'is a directory' do
|
564
|
-
should_list_cookbooks
|
565
|
-
nonexistent_child.dir?.should be_false
|
566
|
-
end
|
567
|
-
it 'read returns NotFoundError' do
|
568
|
-
should_list_cookbooks
|
569
|
-
expect { nonexistent_child.read }.to raise_error(ChefFS::FileSystem::NotFoundError)
|
570
|
-
end
|
571
|
-
end
|
572
|
-
|
573
165
|
end
|