1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { parseKeepManifestText, parseKeepManifestStream, stringifyKeepManifest } from "./collection-manifest-parser";
7 describe('parseKeepManifestText', () => {
8 it('should parse text into streams', () => {
9 const manifestText = `. 930625b054ce894ac40596c3f5a0d947+33 0:0:a 0:0:b 0:33:output.txt\n./c d41d8cd98f00b204e9800998ecf8427e+0 0:0:d\n`;
10 const manifest = parseKeepManifestText(manifestText);
11 expect(manifest[0].name).toBe('');
12 expect(manifest[1].name).toBe('/c');
13 expect(manifest.length).toBe(2);
17 describe('parseKeepManifestStream', () => {
18 const streamText = './c 930625b054ce894ac40596c3f5a0d947+33 0:0:a 0:0:b 0:33:output.txt';
19 const stream = parseKeepManifestStream(streamText);
21 it('should parse stream name', () => {
22 expect(stream.name).toBe('/c');
24 it('should parse stream locators', () => {
25 expect(stream.locators).toEqual(['930625b054ce894ac40596c3f5a0d947+33']);
27 it('should parse stream files', () => {
28 expect(stream.files).toEqual([
29 { name: 'a', position: '0', size: 0 },
30 { name: 'b', position: '0', size: 0 },
31 { name: 'output.txt', position: '0', size: 33 },
36 test('stringifyKeepManifest', () => {
37 const manifestText = `. 930625b054ce894ac40596c3f5a0d947+33 0:22:test.txt\n./c/user/results 930625b054ce894ac40596c3f5a0d947+33 0:0:a 0:0:b 0:33:output.txt\n`;
38 const manifest = parseKeepManifestText(manifestText);
39 expect(stringifyKeepManifest(manifest)).toEqual(`. 930625b054ce894ac40596c3f5a0d947+33 0:22:test.txt\n./c/user/results 930625b054ce894ac40596c3f5a0d947+33 0:0:a 0:0:b 0:33:output.txt\n`);