3 class CollectionTest < ActiveSupport::TestCase
4 test 'recognize empty blob locator' do
5 ['d41d8cd98f00b204e9800998ecf8427e+0',
6 'd41d8cd98f00b204e9800998ecf8427e',
7 'd41d8cd98f00b204e9800998ecf8427e+0+Xyzzy'].each do |x|
8 assert_equal true, Collection.is_empty_blob_locator?(x)
10 ['d41d8cd98f00b204e9800998ecf8427e0',
11 'acbd18db4cc2f85cedef654fccc4a4d8+3',
12 'acbd18db4cc2f85cedef654fccc4a4d8+0'].each do |x|
13 assert_equal false, Collection.is_empty_blob_locator?(x)
17 def get_files_tree(coll_name)
19 Collection.find(api_fixture('collections')[coll_name]['uuid']).files_tree
22 test "easy files_tree" do
23 files_in = lambda do |dirname|
24 (1..3).map { |n| [dirname, "file#{n}", 0] }
26 assert_equal([['.', 'dir1', nil], ['./dir1', 'subdir', nil]] +
27 files_in['./dir1/subdir'] + files_in['./dir1'] +
28 [['.', 'dir2', nil]] + files_in['./dir2'] + files_in['.'],
29 get_files_tree('multilevel_collection_1'),
30 "Collection file tree was malformed")
33 test "files_tree with files deep in subdirectories" do
34 # This test makes sure files_tree generates synthetic directory entries.
35 # The manifest doesn't list directories with no files.
36 assert_equal([['.', 'dir1', nil], ['./dir1', 'sub1', nil],
37 ['./dir1/sub1', 'a', 0], ['./dir1/sub1', 'b', 0],
38 ['.', 'dir2', nil], ['./dir2', 'sub2', nil],
39 ['./dir2/sub2', 'c', 0], ['./dir2/sub2', 'd', 0]],
40 get_files_tree('multilevel_collection_2'),
41 "Collection file tree was malformed")