From c674ad75c9170f562555eae5e8f672de1901e62f Mon Sep 17 00:00:00 2001 From: Victor Bjelkholm Date: Fri, 9 Sep 2016 18:03:41 +0200 Subject: [PATCH 1/2] Check files.get includes paths/content instead of deepEqual This ensures that the files and their path is in the response and ignores the order that we cannot trust --- src/files.js | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/files.js b/src/files.js index 6bdf73e2..1667389e 100644 --- a/src/files.js +++ b/src/files.js @@ -382,34 +382,30 @@ module.exports = (common) => { var paths = files.map((file) => { return file.path }) - expect(paths).to.deep.equal([ - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/empty-folder', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files/empty', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files/hello.txt', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files/ipfs.txt', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/holmes.txt', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt', - 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' - ]) + expect(paths).to.include.members([ + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/empty-folder', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files/empty', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files/hello.txt', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/files/ipfs.txt', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/holmes.txt', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' + ]); // Check contents - var contents = files.map((file) => { - return file.content ? file.content : null - }) - expect(contents).to.deep.equal([ - null, - directoryContent['alice.txt'], - null, - null, - null, - directoryContent['files/hello.txt'], - directoryContent['files/ipfs.txt'], - directoryContent['holmes.txt'], - directoryContent['jungle.txt'], - directoryContent['pp.txt'] + var contents = files.map(function (file) { + return file.content ? file.content.toString() : null + }); + expect(contents).to.include.members([ + directoryContent['alice.txt'].toString(), + directoryContent['files/hello.txt'].toString(), + directoryContent['files/ipfs.txt'].toString(), + directoryContent['holmes.txt'].toString(), + directoryContent['jungle.txt'].toString(), + directoryContent['pp.txt'].toString() ]) done() })) From 7a913c1e0db85be449ba7fc3ccaa5234251e564c Mon Sep 17 00:00:00 2001 From: Victor Bjelkholm Date: Fri, 9 Sep 2016 18:11:33 +0200 Subject: [PATCH 2/2] Fix lint issues --- src/files.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/files.js b/src/files.js index 1667389e..4e950a62 100644 --- a/src/files.js +++ b/src/files.js @@ -383,22 +383,22 @@ module.exports = (common) => { return file.path }) expect(paths).to.include.members([ - 'QmVvj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y7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/jungle.txt', + 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/pp.txt' + ]) // Check contents var contents = files.map(function (file) { return file.content ? file.content.toString() : null - }); + }) expect(contents).to.include.members([ directoryContent['alice.txt'].toString(), directoryContent['files/hello.txt'].toString(),