+
+ def test_has_file_with_spaces
+ manifest = Keep::Manifest.new(". #{random_block(3)} 0:3:a\\040b\\040c\n")
+ assert(manifest.has_file?("./a b c"), "one-arg 'a b c' not found")
+ assert(manifest.has_file?(".", "a b c"), "two-arg 'a b c' not found")
+ refute(manifest.has_file?("a\\040b\\040c"), "one-arg unescaped found")
+ refute(manifest.has_file?(".", "a\\040b\\040c"), "two-arg unescaped found")
+ end
+
+ def test_parse_all_fixtures
+ fixtures('collections').each do |name, collection|
+ parse_collection_manifest name, collection
+ end
+ end
+
+ def test_raise_on_bogus_fixture
+ assert_raises ArgumentError do
+ parse_collection_manifest('bogus collection',
+ {'manifest_text' => ". zzz 0:\n"})
+ end
+ end
+
+ def parse_collection_manifest name, collection
+ manifest = Keep::Manifest.new(collection['manifest_text'])
+ manifest.each_file_spec do |stream_name, start_pos, file_size, file_name|
+ assert_kind_of String, stream_name
+ assert_kind_of Integer, start_pos
+ assert_kind_of Integer, file_size
+ assert_kind_of String, file_name
+ assert !stream_name.empty?, "empty stream_name in #{name} fixture"
+ assert !file_name.empty?, "empty file_name in #{name} fixture"
+ end
+ end
+
+ @@fixtures = nil
+ def fixtures name
+ return @@fixtures if @@fixtures
+ path = File.expand_path("../../../../services/api/test/fixtures/#{name}.yml",
+ __FILE__)
+ file = IO.read(path)
+ trim_index = file.index('# Test Helper trims the rest of the file')
+ file = file[0, trim_index] if trim_index
+ @@fixtures = YAML.load(file)
+ end