5 # SDKFixtures will use these as class methods, and install them as
6 # instance methods on the test classes.
7 def random_block(size=nil)
8 sprintf("%032x+%d", rand(16 ** 32), size || rand(64 * 1024 * 1024))
11 def random_blocks(count, size=nil)
12 (0...count).map { |_| random_block(size) }
18 def self.included(base)
19 base.include(StaticMethods)
27 expand_path("../../../../services/api/test/fixtures/#{name}.yml",
30 trim_index = file.index('# Test Helper trims the rest of the file')
31 file = file[0, trim_index] if trim_index
37 SIMPLEST_MANIFEST = ". #{random_block(9)} 0:9:simple.txt\n"
38 MULTIBLOCK_FILE_MANIFEST =
39 [". #{random_block(8)} 0:4:repfile 4:4:uniqfile",
40 "./s1 #{random_block(6)} 0:3:repfile 3:3:uniqfile",
41 ". #{random_block(8)} 0:7:uniqfile2 7:1:repfile\n"].join("\n")
43 [". #{random_block(9)} 0:3:file1 3:3:file2 6:3:file3\n",
44 "./dir0 #{random_block(9)} 0:3:file1 3:3:file2 6:3:file3\n",
45 "./dir0/subdir #{random_block(9)} 0:3:file1 3:3:file2 6:3:file3\n",
46 "./dir1 #{random_block(9)} 0:3:file1 3:3:file2 6:3:file3\n",
47 "./dir1/subdir #{random_block(9)} 0:3:file1 3:3:file2 6:3:file3\n",
48 "./dir2 #{random_block(9)} 0:3:file1 3:3:file2 6:3:file3\n"].join("")
49 COLON_FILENAME_MANIFEST = ". #{random_block(9)} 0:9:file:test.txt\n"
50 # Filename is `a a.txt`.
51 ESCAPED_FILENAME_MANIFEST = ". #{random_block(9)} 0:9:a\\040\\141.txt\n"
52 MANY_ESCAPES_MANIFEST =
53 "./dir\\040name #{random_block(9)} 0:9:file\\\\name\\011\\here.txt\n"
54 NONNORMALIZED_MANIFEST =
55 ["./dir2 #{random_block} 0:0:z 0:0:y 0:0:x",
56 "./dir1 #{random_block} 0:0:p 0:0:o 0:0:n\n"].join("\n")
57 MULTILEVEL_MANIFEST_WITH_DIRS_IN_FILENAMES =
58 [". #{random_block(10)} 0:3:file1 3:3:dir1/file1 6:3:dir1/dir2/file1\n"].join("")
60 ### Non-tree manifests
61 # These manifests follow the spec, but they express a structure that can't
62 # can't be represented by a POSIX filesystem tree. For example, there's a
63 # name conflict between a stream and a filename.
64 NAME_CONFLICT_MANIFEST =
65 [". #{random_block(9)} 0:9:conflict",
66 "./conflict #{random_block} 0:0:name\n"].join("\n")