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