1 require "arvados/collection"
2 require "minitest/autorun"
5 class CollectionTest < Minitest::Test
8 TWO_BY_TWO_BLOCKS = SDKFixtures.random_blocks(2, 9)
9 TWO_BY_TWO_MANIFEST_A =
10 [". #{TWO_BY_TWO_BLOCKS.first} 0:5:f1 5:4:f2\n",
11 "./s1 #{TWO_BY_TWO_BLOCKS.last} 0:5:f1 5:4:f3\n"]
12 TWO_BY_TWO_MANIFEST_S = TWO_BY_TWO_MANIFEST_A.join("")
16 def test_empty_construction
17 coll = Arv::Collection.new
18 assert_equal("", coll.manifest_text)
21 def test_successful_construction
22 [:SIMPLEST_MANIFEST, :MULTIBLOCK_FILE_MANIFEST, :MULTILEVEL_MANIFEST].
23 each do |manifest_name|
24 manifest_text = SDKFixtures.const_get(manifest_name)
25 coll = Arv::Collection.new(manifest_text)
26 assert_equal(manifest_text, coll.manifest_text,
27 "did not get same manifest back out from #{manifest_name}")
31 def test_non_manifest_construction_error
32 ["word", ". abc def", ". #{random_block} 0:", ". / !"].each do |m_text|
33 assert_raises(ArgumentError,
34 "built collection from manifest #{m_text.inspect}") do
35 Arv::Collection.new(m_text)
40 def test_file_directory_conflict_construction_error
41 assert_raises(ArgumentError) do
42 Arv::Collection.new(NAME_CONFLICT_MANIFEST)
46 def test_no_implicit_normalization
47 coll = Arv::Collection.new(NONNORMALIZED_MANIFEST)
48 assert_equal(NONNORMALIZED_MANIFEST, coll.manifest_text)
53 def test_non_posix_path_handling
54 m_text = "./.. #{random_block(9)} 0:5:. 5:4:..\n"
55 coll = Arv::Collection.new(m_text.dup)
57 assert_equal(m_text, coll.manifest_text)
60 def test_escaping_through_normalization
61 coll = Arv::Collection.new(MANY_ESCAPES_MANIFEST)
63 # The result should simply duplicate the file spec.
64 # The source file spec has an unescaped backslash in it.
65 # It's OK for the Collection class to properly escape that.
66 expect_text = MANY_ESCAPES_MANIFEST.sub(/ \d+:\d+:\S+/) do |file_spec|
67 file_spec.gsub(/([^\\])(\\[^\\\d])/, '\1\\\\\2')
69 assert_equal(expect_text, coll.manifest_text)
72 def test_concatenation_with_locator_overlap(over_index=0)
73 blocks = random_blocks(4, 2)
74 blocks_s = blocks.join(" ")
75 coll = Arv::Collection.new(". %s 0:8:file\n. %s 0:4:file\n" %
76 [blocks_s, blocks[over_index, 2].join(" ")])
78 assert_equal(". #{blocks_s} 0:8:file #{over_index * 2}:4:file\n",
82 def test_concatenation_with_middle_locator_overlap
83 test_concatenation_with_locator_overlap(1)
86 def test_concatenation_with_end_locator_overlap
87 test_concatenation_with_locator_overlap(2)
90 def test_concatenation_with_partial_locator_overlap
91 blocks = random_blocks(3, 3)
92 coll = Arv::Collection
93 .new(". %s 0:6:overlap\n. %s 0:6:overlap\n" %
94 [blocks[0, 2].join(" "), blocks[1, 2].join(" ")])
96 assert_equal(". #{blocks.join(' ')} 0:6:overlap 3:6:overlap\n",
102 coll = Arv::Collection.new(". #{block} 0:0:f2 0:0:f1\n")
104 assert_equal(". #{block} 0:0:f1 0:0:f2\n", coll.manifest_text)
107 def test_normalization_file_spans_two_whole_blocks(file_specs="0:10:f1",
109 blocks = random_blocks(num_blocks, 5)
110 m_text = ". #{blocks.join(' ')} #{file_specs}\n"
111 coll = Arv::Collection.new(m_text.dup)
113 assert_equal(m_text, coll.manifest_text)
116 def test_normalization_file_fits_beginning_block
117 test_normalization_file_spans_two_whole_blocks("0:7:f1")
120 def test_normalization_file_fits_end_block
121 test_normalization_file_spans_two_whole_blocks("3:7:f1")
124 def test_normalization_file_spans_middle
125 test_normalization_file_spans_two_whole_blocks("3:5:f1")
128 def test_normalization_file_spans_three_whole_blocks
129 test_normalization_file_spans_two_whole_blocks("0:15:f1", 3)
132 def test_normalization_file_skips_bytes
133 test_normalization_file_spans_two_whole_blocks("0:3:f1 5:5:f1")
136 def test_normalization_file_inserts_bytes
137 test_normalization_file_spans_two_whole_blocks("0:3:f1 5:3:f1 3:2:f1")
140 def test_normalization_file_duplicates_bytes
141 test_normalization_file_spans_two_whole_blocks("2:3:f1 2:3:f1", 1)
144 def test_normalization_dedups_locators
145 blocks = random_blocks(2, 5)
146 coll = Arv::Collection.new(". %s %s 1:8:f1 11:8:f1\n" %
147 [blocks.join(" "), blocks.reverse.join(" ")])
149 assert_equal(". #{blocks.join(' ')} 1:8:f1 6:4:f1 0:4:f1\n",
155 def test_simple_file_copy
156 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
157 coll.cp_r("./simple.txt", "./new")
158 assert_equal(SIMPLEST_MANIFEST.sub(" 0:9:", " 0:9:new 0:9:"),
162 def test_copy_file_into_other_stream(target="./s1/f2", basename="f2")
163 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
164 coll.cp_r("./f2", target)
165 expected = "%s./s1 %s 0:5:f1 14:4:%s 5:4:f3\n" %
166 [TWO_BY_TWO_MANIFEST_A.first,
167 TWO_BY_TWO_BLOCKS.reverse.join(" "), basename]
168 assert_equal(expected, coll.manifest_text)
171 def test_implicit_copy_file_into_other_stream
172 test_copy_file_into_other_stream("./s1")
175 def test_copy_file_into_other_stream_with_new_name
176 test_copy_file_into_other_stream("./s1/f2a", "f2a")
179 def test_copy_file_over_in_other_stream(target="./s1/f1")
180 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
181 coll.cp_r("./f1", target)
182 expected = "%s./s1 %s 0:5:f1 14:4:f3\n" %
183 [TWO_BY_TWO_MANIFEST_A.first, TWO_BY_TWO_BLOCKS.join(" ")]
184 assert_equal(expected, coll.manifest_text)
187 def test_implicit_copy_file_over_in_other_stream
188 test_copy_file_over_in_other_stream("./s1")
191 def test_simple_stream_copy
192 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
193 coll.cp_r("./s1", "./sNew")
194 new_line = TWO_BY_TWO_MANIFEST_A.last.sub("./s1 ", "./sNew ")
195 assert_equal(TWO_BY_TWO_MANIFEST_S + new_line, coll.manifest_text)
198 def test_copy_stream_into_other_stream(target="./dir2/subdir",
200 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
201 coll.cp_r("./dir1/subdir", target)
202 new_line = MULTILEVEL_MANIFEST.lines[4].sub("./dir1/subdir ",
203 "./dir2/#{basename} ")
204 assert_equal(MULTILEVEL_MANIFEST + new_line, coll.manifest_text)
207 def test_implicit_copy_stream_into_other_stream
208 test_copy_stream_into_other_stream("./dir2")
211 def test_copy_stream_into_other_stream_with_new_name
212 test_copy_stream_into_other_stream("./dir2/newsub", "newsub")
215 def test_copy_stream_over_empty_stream
216 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
217 (1..3).each do |file_num|
218 coll.rm("./dir0/subdir/file#{file_num}")
220 coll.cp_r("./dir1/subdir", "./dir0")
221 expected = MULTILEVEL_MANIFEST.lines
222 expected[2] = expected[4].sub("./dir1/", "./dir0/")
223 assert_equal(expected.join(""), coll.manifest_text)
226 def test_copy_stream_over_file_raises_ENOTDIR(source="./s1", target="./f2")
227 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
228 assert_raises(Errno::ENOTDIR) do
229 coll.cp_r(source, target)
233 def test_copy_file_under_file_raises_ENOTDIR
234 test_copy_stream_over_file_raises_ENOTDIR("./f1", "./f2/newfile")
237 def test_copy_stream_over_nonempty_stream_merges_and_overwrites
238 blocks = random_blocks(3, 9)
240 ["./subdir #{blocks[0]} 0:1:s1 1:2:zero\n",
241 "./zdir #{blocks[1]} 0:9:zfile\n",
242 "./zdir/subdir #{blocks[2]} 0:1:s2 1:2:zero\n"]
243 coll = Arv::Collection.new(manifest_a.join(""))
244 coll.cp_r("./subdir", "./zdir")
245 manifest_a[2] = "./zdir/subdir %s %s 0:1:s1 9:1:s2 1:2:zero\n" %
246 [blocks[0], blocks[2]]
247 assert_equal(manifest_a.join(""), coll.manifest_text)
250 def test_copy_stream_into_substream(source="./dir1",
251 target="./dir1/subdir/dir1")
252 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
253 coll.cp_r(source, target)
254 expected = MULTILEVEL_MANIFEST.lines.flat_map do |line|
255 [line, line.gsub(/^#{Regexp.escape(source)}([\/ ])/, "#{target}\\1")].uniq
257 assert_equal(expected.sort.join(""), coll.manifest_text)
261 test_copy_stream_into_substream(".", "./root")
264 def test_adding_to_root_after_copy
265 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
266 coll.cp_r(".", "./root")
267 src_coll = Arv::Collection.new(COLON_FILENAME_MANIFEST)
268 coll.cp_r("./file:test.txt", ".", src_coll)
269 got_lines = coll.manifest_text.lines
270 assert_equal(2, got_lines.size)
271 assert_match(/^\. \S{33,} \S{33,} 0:9:file:test\.txt 9:9:simple\.txt\n/,
273 assert_equal(SIMPLEST_MANIFEST.sub(". ", "./root "), got_lines.last)
276 def test_copy_chaining
277 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
278 coll.cp_r("./simple.txt", "./a").cp_r("./a", "./b")
279 assert_equal(SIMPLEST_MANIFEST.sub(" 0:9:", " 0:9:a 0:9:b 0:9:"),
283 def prep_two_collections_for_copy(src_stream, dst_stream)
284 blocks = random_blocks(2, 8)
285 src_text = "#{src_stream} #{blocks.first} 0:8:f1\n"
286 dst_text = "#{dst_stream} #{blocks.last} 0:8:f2\n"
287 return [blocks, src_text, dst_text,
288 Arv::Collection.new(src_text.dup),
289 Arv::Collection.new(dst_text.dup)]
292 def test_copy_file_from_other_collection(src_stream=".", dst_stream="./s1")
293 blocks, src_text, dst_text, src_coll, dst_coll =
294 prep_two_collections_for_copy(src_stream, dst_stream)
295 dst_coll.cp_r("#{src_stream}/f1", dst_stream, src_coll)
296 assert_equal("#{dst_stream} #{blocks.join(' ')} 0:8:f1 8:8:f2\n",
297 dst_coll.manifest_text)
298 assert_equal(src_text, src_coll.manifest_text)
301 def test_copy_file_from_other_collection_to_root
302 test_copy_file_from_other_collection("./s1", ".")
305 def test_copy_stream_from_other_collection
306 blocks, src_text, dst_text, src_coll, dst_coll =
307 prep_two_collections_for_copy("./s2", "./s1")
308 dst_coll.cp_r("./s2", "./s1", src_coll)
309 assert_equal(dst_text + src_text.sub("./s2 ", "./s1/s2 "),
310 dst_coll.manifest_text)
311 assert_equal(src_text, src_coll.manifest_text)
314 def test_copy_stream_from_other_collection_to_root
315 blocks, src_text, dst_text, src_coll, dst_coll =
316 prep_two_collections_for_copy("./s1", ".")
317 dst_coll.cp_r("./s1", ".", src_coll)
318 assert_equal(dst_text + src_text, dst_coll.manifest_text)
319 assert_equal(src_text, src_coll.manifest_text)
322 def test_copy_stream_contents
323 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
324 coll.cp_r("./dir0/subdir/", "./dir1/subdir")
325 expect_lines = MULTILEVEL_MANIFEST.lines
326 expect_lines[4] = expect_lines[2].sub("./dir0/", "./dir1/")
327 assert_equal(expect_lines.join(""), coll.manifest_text)
330 def test_copy_file_into_new_stream_with_implicit_filename
331 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
332 coll.cp_r("./simple.txt", "./new/")
333 assert_equal(SIMPLEST_MANIFEST + SIMPLEST_MANIFEST.sub(". ", "./new "),
337 def test_copy_file_into_new_stream_with_explicit_filename
338 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
339 coll.cp_r("./simple.txt", "./new/newfile.txt")
340 new_line = SIMPLEST_MANIFEST.sub(". ", "./new ").sub(":simple", ":newfile")
341 assert_equal(SIMPLEST_MANIFEST + new_line, coll.manifest_text)
344 def test_copy_stream_contents_into_root
345 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
346 coll.cp_r("./s1/", ".")
347 assert_equal(". %s 0:5:f1 14:4:f2 5:4:f3\n%s" %
348 [TWO_BY_TWO_BLOCKS.reverse.join(" "),
349 TWO_BY_TWO_MANIFEST_A.last],
353 def test_copy_root_contents_into_stream
354 # This is especially fun, because we're copying a parent into its child.
355 # Make sure that happens depth-first.
356 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
357 coll.cp_r("./", "./s1")
358 assert_equal("%s./s1 %s 0:5:f1 5:4:f2 14:4:f3\n%s" %
359 [TWO_BY_TWO_MANIFEST_A.first, TWO_BY_TWO_BLOCKS.join(" "),
360 TWO_BY_TWO_MANIFEST_A.last.sub("./s1 ", "./s1/s1 ")],
364 def test_copy_stream_contents_across_collections
365 block = random_block(8)
366 src_coll = Arv::Collection.new("./s1 #{block} 0:8:f1\n")
367 dst_coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
368 dst_coll.cp_r("./s1/", "./s1", src_coll)
369 assert_equal("%s./s1 %s %s 0:8:f1 13:4:f3\n" %
370 [TWO_BY_TWO_MANIFEST_A.first, block, TWO_BY_TWO_BLOCKS.last],
371 dst_coll.manifest_text)
374 def test_copy_root_contents_across_collections
375 block = random_block(8)
376 src_coll = Arv::Collection.new(". #{block} 0:8:f1\n")
377 dst_coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
378 dst_coll.cp_r("./", ".", src_coll)
379 assert_equal(". %s %s 0:8:f1 13:4:f2\n%s" %
380 [block, TWO_BY_TWO_BLOCKS.first, TWO_BY_TWO_MANIFEST_A.last],
381 dst_coll.manifest_text)
384 def test_copy_empty_source_path_raises_ArgumentError(src="", dst="./s1")
385 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
386 assert_raises(ArgumentError) do
391 def test_copy_empty_destination_path_raises_ArgumentError
392 test_copy_empty_source_path_raises_ArgumentError(".", "")
397 def test_each_file_path
398 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
403 coll.each_file_path { |path| result << path }
405 assert_equal(["./f1", "./f2", "./s1/f1", "./s1/f3"], result.sort)
408 def test_each_file_path_without_block
409 test_each_file_path { |coll| coll.each_file_path.to_a }
412 def test_each_file_path_empty_collection
413 assert_empty(Arv::Collection.new.each_file_path.to_a)
416 def test_each_file_path_after_collection_emptied
417 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
418 coll.rm("simple.txt")
419 assert_empty(coll.each_file_path.to_a)
422 def test_each_file_path_deduplicates_manifest_listings
423 coll = Arv::Collection.new(MULTIBLOCK_FILE_MANIFEST)
424 assert_equal(["./repfile", "./s1/repfile", "./s1/uniqfile",
425 "./uniqfile", "./uniqfile2"],
426 coll.each_file_path.to_a.sort)
431 def test_exist(test_method=:assert, path="f2")
432 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
433 send(test_method, coll.exist?(path))
436 def test_file_not_exist
437 test_exist(:refute, "f3")
440 def test_stream_exist
441 test_exist(:assert, "s1")
444 def test_file_inside_stream_exist
445 test_exist(:assert, "s1/f1")
448 def test_path_inside_stream_not_exist
449 test_exist(:refute, "s1/f2")
452 def test_path_under_file_not_exist
453 test_exist(:refute, "f2/nonexistent")
456 def test_deep_substreams_not_exist
457 test_exist(:refute, "a/b/c/d/e/f/g")
462 def test_simple_file_rename
463 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
464 coll.rename("./simple.txt", "./new")
465 assert_equal(SIMPLEST_MANIFEST.sub(":simple.txt", ":new"),
469 def test_rename_file_into_other_stream(target="./s1/f2", basename="f2")
470 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
471 coll.rename("./f2", target)
472 expected = ". %s 0:5:f1\n./s1 %s 0:5:f1 14:4:%s 5:4:f3\n" %
473 [TWO_BY_TWO_BLOCKS.first,
474 TWO_BY_TWO_BLOCKS.reverse.join(" "), basename]
475 assert_equal(expected, coll.manifest_text)
478 def test_implicit_rename_file_into_other_stream
479 test_rename_file_into_other_stream("./s1")
482 def test_rename_file_into_other_stream_with_new_name
483 test_rename_file_into_other_stream("./s1/f2a", "f2a")
486 def test_rename_file_over_in_other_stream(target="./s1/f1")
487 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
488 coll.rename("./f1", target)
489 expected = ". %s 5:4:f2\n./s1 %s 0:5:f1 14:4:f3\n" %
490 [TWO_BY_TWO_BLOCKS.first, TWO_BY_TWO_BLOCKS.join(" ")]
491 assert_equal(expected, coll.manifest_text)
494 def test_implicit_rename_file_over_in_other_stream
495 test_rename_file_over_in_other_stream("./s1")
498 def test_simple_stream_rename
499 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
500 coll.rename("./s1", "./newS")
501 assert_equal(TWO_BY_TWO_MANIFEST_S.sub("\n./s1 ", "\n./newS "),
505 def test_rename_stream_into_other_stream(target="./dir2/subdir",
507 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
508 coll.rename("./dir1/subdir", target)
509 expected = MULTILEVEL_MANIFEST.lines
510 replaced_line = expected.delete_at(4)
511 expected << replaced_line.sub("./dir1/subdir ", "./dir2/#{basename} ")
512 assert_equal(expected.join(""), coll.manifest_text)
515 def test_implicit_rename_stream_into_other_stream
516 test_rename_stream_into_other_stream("./dir2")
519 def test_rename_stream_into_other_stream_with_new_name
520 test_rename_stream_into_other_stream("./dir2/newsub", "newsub")
523 def test_rename_stream_over_empty_stream
524 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
525 (1..3).each do |file_num|
526 coll.rm("./dir0/subdir/file#{file_num}")
528 coll.rename("./dir1/subdir", "./dir0")
529 expected = MULTILEVEL_MANIFEST.lines
530 expected[2] = expected.delete_at(4).sub("./dir1/", "./dir0/")
531 assert_equal(expected.sort.join(""), coll.manifest_text)
534 def test_rename_stream_over_file_raises_ENOTDIR
535 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
536 assert_raises(Errno::ENOTDIR) do
537 coll.rename("./s1", "./f2")
541 def test_rename_stream_over_nonempty_stream_raises_ENOTEMPTY
542 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
543 assert_raises(Errno::ENOTEMPTY) do
544 coll.rename("./dir1/subdir", "./dir0")
548 def test_rename_stream_into_substream(source="./dir1",
549 target="./dir1/subdir/dir1")
550 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
551 coll.rename(source, target)
552 assert_equal(MULTILEVEL_MANIFEST.gsub(/^#{Regexp.escape(source)}([\/ ])/m,
558 test_rename_stream_into_substream(".", "./root")
561 def test_adding_to_root_after_rename
562 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
563 coll.rename(".", "./root")
564 src_coll = Arv::Collection.new(SIMPLEST_MANIFEST)
565 coll.cp_r("./simple.txt", ".", src_coll)
566 assert_equal(SIMPLEST_MANIFEST + SIMPLEST_MANIFEST.sub(". ", "./root "),
570 def test_rename_chaining
571 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
572 coll.rename("./simple.txt", "./x").rename("./x", "./simple.txt")
573 assert_equal(SIMPLEST_MANIFEST, coll.manifest_text)
578 def test_simple_remove
579 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S.dup)
581 assert_equal(TWO_BY_TWO_MANIFEST_S.sub(" 5:4:f2", ""), coll.manifest_text)
584 def empty_stream_and_assert(expect_index=0)
585 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
587 assert_equal(TWO_BY_TWO_MANIFEST_A[expect_index], coll.manifest_text)
590 def test_remove_all_files_in_substream
591 empty_stream_and_assert do |coll|
597 def test_remove_all_files_in_root_stream
598 empty_stream_and_assert(1) do |coll|
604 def test_chaining_removes
605 empty_stream_and_assert do |coll|
606 coll.rm("./s1/f1").rm("./s1/f3")
610 def test_remove_last_file
611 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
612 coll.rm("./simple.txt")
613 assert_equal("", coll.manifest_text)
616 def test_remove_nonexistent_file_raises_ENOENT(path="./NoSuchFile",
618 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
619 assert_raises(Errno::ENOENT) do
620 coll.send(method, path)
624 def test_remove_from_nonexistent_stream_raises_ENOENT
625 test_remove_nonexistent_file_raises_ENOENT("./NoSuchStream/simple.txt")
628 def test_remove_stream_raises_EISDIR(path="./s1")
629 coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S)
630 assert_raises(Errno::EISDIR) do
635 def test_remove_root_raises_EISDIR
636 test_remove_stream_raises_EISDIR(".")
639 def test_remove_empty_string_raises_ArgumentError
640 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
641 assert_raises(ArgumentError) do
648 def test_recursive_remove
649 empty_stream_and_assert do |coll|
654 def test_recursive_remove_on_files
655 empty_stream_and_assert do |coll|
661 def test_recursive_remove_root
662 coll = Arv::Collection.new(MULTILEVEL_MANIFEST)
664 assert_equal("", coll.manifest_text)
667 def test_rm_r_nonexistent_file_raises_ENOENT(path="./NoSuchFile")
668 test_remove_nonexistent_file_raises_ENOENT("./NoSuchFile", :rm_r)
671 def test_rm_r_from_nonexistent_stream_raises_ENOENT
672 test_remove_nonexistent_file_raises_ENOENT("./NoSuchStream/file", :rm_r)
675 def test_rm_r_empty_string_raises_ArgumentError
676 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
677 assert_raises(ArgumentError) do
684 def test_new_collection_unmodified(*args)
685 coll = Arv::Collection.new(*args)
686 yield coll if block_given?
687 refute(coll.modified?)
690 def test_collection_unmodified_after_instantiation
691 test_new_collection_unmodified(SIMPLEST_MANIFEST)
694 def test_collection_unmodified_after_mark
695 test_new_collection_unmodified(SIMPLEST_MANIFEST) do |coll|
696 coll.cp_r("./simple.txt", "./copy")
701 def check_collection_modified
702 coll = Arv::Collection.new(SIMPLEST_MANIFEST)
704 assert(coll.modified?)
707 def test_collection_modified_after_copy
708 check_collection_modified do |coll|
709 coll.cp_r("./simple.txt", "./copy")
713 def test_collection_modified_after_remove
714 check_collection_modified do |coll|
715 coll.rm("./simple.txt")
719 def test_collection_modified_after_rename
720 check_collection_modified do |coll|
721 coll.rename("./simple.txt", "./newname")