X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ad5512c3aafbed2e97ea5c24442fcd2d17a35edf..50031c8c6aae1f325f81d71a6f5a8c1cb293aa46:/src/services/collection-files-service/collection-manifest-mapper.test.ts diff --git a/src/services/collection-files-service/collection-manifest-mapper.test.ts b/src/services/collection-files-service/collection-manifest-mapper.test.ts new file mode 100644 index 00000000..ad8f8727 --- /dev/null +++ b/src/services/collection-files-service/collection-manifest-mapper.test.ts @@ -0,0 +1,59 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { parseKeepManifestText } from "./collection-manifest-parser"; +import { mapManifestToFiles, mapManifestToDirectories } from "./collection-manifest-mapper"; + +test('mapManifestToFiles', () => { + const manifestText = `. 930625b054ce894ac40596c3f5a0d947+33 0:0:a 0:0:b 0:33:output.txt\n./c d41d8cd98f00b204e9800998ecf8427e+0 0:0:d`; + const manifest = parseKeepManifestText(manifestText); + const files = mapManifestToFiles(manifest); + expect(files).toEqual([{ + parentId: '', + id: '/a', + name: 'a', + size: 0, + type: 'file' + }, { + parentId: '', + id: '/b', + name: 'b', + size: 0, + type: 'file' + }, { + parentId: '', + id: '/output.txt', + name: 'output.txt', + size: 33, + type: 'file' + }, { + parentId: '/c', + id: '/c/d', + name: 'd', + size: 0, + type: 'file' + },]); +}); + +test('mapManifestToDirectories', () => { + const manifestText = `./c/user/results 930625b054ce894ac40596c3f5a0d947+33 0:0:a 0:0:b 0:33:output.txt\n`; + const manifest = parseKeepManifestText(manifestText); + const directories = mapManifestToDirectories(manifest); + expect(directories).toEqual([{ + parentId: "", + id: '/c', + name: 'c', + type: 'directory' + }, { + parentId: '/c', + id: '/c/user', + name: 'user', + type: 'directory' + }, { + parentId: '/c/user', + id: '/c/user/results', + name: 'results', + type: 'directory' + },]); +}); \ No newline at end of file