[ARVADOS-WORKBENCH2] updated: 1.1.4-462-g3120740

Git user git at public.curoverse.com
Tue Jul 31 08:12:55 EDT 2018


Summary of changes:
 src/models/keep-manifest.test.ts | 17 +++++++++--------
 src/models/keep-manifest.ts      | 17 ++++++++++-------
 2 files changed, 19 insertions(+), 15 deletions(-)

       via  3120740061c64645fe8a2015c075add657563921 (commit)
      from  1c7242e61e9d71c7a37483ec0583dd0256f8ee7e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 3120740061c64645fe8a2015c075add657563921
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Jul 31 14:12:38 2018 +0200

    Update keep manifest naming, fix splitting up the manifest text
    
    Feature #13855
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/models/keep-manifest.test.ts b/src/models/keep-manifest.test.ts
index 7de816c..d9c4967 100644
--- a/src/models/keep-manifest.test.ts
+++ b/src/models/keep-manifest.test.ts
@@ -5,11 +5,12 @@
 import { parseKeepManifestText, parseKeepManifestStream } from "./keep-manifest";
 
 describe('parseKeepManifestText', () => {
-    it('should return correct number of streams', () => {
-        const manifestText = `. 930625b054ce894ac40596c3f5a0d947+33 0:0:a 0:0:b 0:33:output.txt
-        ./c d41d8cd98f00b204e9800998ecf8427e+0 0:0:d`;
+    it('should parse text into streams', () => {
+        const manifestText = `. 930625b054ce894ac40596c3f5a0d947+33 0:0:a 0:0:b 0:33:output.txt\n./c d41d8cd98f00b204e9800998ecf8427e+0 0:0:d\n`;
         const manifest = parseKeepManifestText(manifestText);
-        expect(manifest).toHaveLength(2);
+        expect(manifest[0].name).toBe('');
+        expect(manifest[1].name).toBe('/c');
+        expect(manifest.length).toBe(2);
     });
 });
 
@@ -18,16 +19,16 @@ describe('parseKeepManifestStream', () => {
     const stream = parseKeepManifestStream(streamText);
 
     it('should parse stream name', () => {
-        expect(stream.streamName).toBe('./c');
+        expect(stream.name).toBe('/c');
     });
     it('should parse stream locators', () => {
         expect(stream.locators).toEqual(['930625b054ce894ac40596c3f5a0d947+33']);
     });
     it('should parse stream files', () => {
         expect(stream.files).toEqual([
-            {fileName: 'a', position: '0', size: 0},
-            {fileName: 'b', position: '0', size: 0},
-            {fileName: 'output.txt', position: '0', size: 33},
+            {name: 'a', position: '0', size: 0},
+            {name: 'b', position: '0', size: 0},
+            {name: 'output.txt', position: '0', size: 33},
         ]);
     });
 });
\ No newline at end of file
diff --git a/src/models/keep-manifest.ts b/src/models/keep-manifest.ts
index 0972e1e..085d910 100644
--- a/src/models/keep-manifest.ts
+++ b/src/models/keep-manifest.ts
@@ -5,13 +5,13 @@
 export type KeepManifest = KeepManifestStream[];
 
 export interface KeepManifestStream {
-    streamName: string;
+    name: string;
     locators: string[];
     files: Array<KeepManifestStreamFile>;
 }
 
 export interface KeepManifestStreamFile {
-    fileName: string;
+    name: string;
     position: string;
     size: number;
 }
@@ -20,7 +20,10 @@ export interface KeepManifestStreamFile {
  * Documentation [http://doc.arvados.org/api/storage.html](http://doc.arvados.org/api/storage.html)
  */
 export const parseKeepManifestText = (text: string) =>
-    text.split(/\n/).map(parseKeepManifestStream);
+    text
+        .split(/\n/)
+        .filter(streamText => streamText.length > 0)
+        .map(parseKeepManifestStream);
 
 /**
  * Documentation [http://doc.arvados.org/api/storage.html](http://doc.arvados.org/api/storage.html)
@@ -28,7 +31,7 @@ export const parseKeepManifestText = (text: string) =>
 export const parseKeepManifestStream = (stream: string): KeepManifestStream => {
     const tokens = stream.split(' ');
     return {
-        streamName: streamName(tokens),
+        name: streamName(tokens),
         locators: locators(tokens),
         files: files(tokens)
     };
@@ -38,7 +41,7 @@ const FILE_LOCATOR_REGEXP = /^([0-9a-f]{32})\+([0-9]+)(\+[A-Z][-A-Za-z0-9 at _]*)*$
 
 const FILE_REGEXP = /([0-9]+):([0-9]+):(.*)/;
 
-const streamName = (tokens: string[]) => tokens[0];
+const streamName = (tokens: string[]) => tokens[0].slice(1);
 
 const locators = (tokens: string[]) => tokens.filter(isFileLocator);
 
@@ -50,6 +53,6 @@ const isFile = (token: string) => FILE_REGEXP.test(token);
 
 const parseFile = (token: string): KeepManifestStreamFile => {
     const match = FILE_REGEXP.exec(token);
-    const [position, size, fileName] = match!.slice(1);
-    return { fileName, position, size: parseInt(size, 10) };
+    const [position, size, name] = match!.slice(1);
+    return { name, position, size: parseInt(size, 10) };
 };
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list