From 3f30830b145ed2b7f36f1c4160b2cbb82cbdd32c Mon Sep 17 00:00:00 2001 From: dirkmc Date: Thu, 16 May 2019 08:59:37 -0600 Subject: [PATCH 1/3] fix: use fixtures for refs tests (#471) * fix: use fixtures for refs tests * fix: config set test * fix: refs tests load data callback * fix: use mapSeries when loading in refs tests * fix: skip failing test for now --- src/files-regular/refs-tests.js | 29 ++++++++++--------- .../refs-test/animals/land/african.txt | 2 ++ .../refs-test/animals/land/americas.txt | 2 ++ .../refs-test/animals/land/australian.txt | 2 ++ .../refs-test/animals/sea/atlantic.txt | 2 ++ .../fixtures/refs-test/animals/sea/indian.txt | 2 ++ test/fixtures/refs-test/atlantic-animals | 2 ++ test/fixtures/refs-test/fruits/tropical.txt | 2 ++ test/fixtures/refs-test/mushroom.txt | 1 + 9 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 test/fixtures/refs-test/animals/land/african.txt create mode 100644 test/fixtures/refs-test/animals/land/americas.txt create mode 100644 test/fixtures/refs-test/animals/land/australian.txt create mode 100644 test/fixtures/refs-test/animals/sea/atlantic.txt create mode 100644 test/fixtures/refs-test/animals/sea/indian.txt create mode 100644 test/fixtures/refs-test/atlantic-animals create mode 100644 test/fixtures/refs-test/fruits/tropical.txt create mode 100644 test/fixtures/refs-test/mushroom.txt diff --git a/src/files-regular/refs-tests.js b/src/files-regular/refs-tests.js index 08414888..f3f8dbbf 100644 --- a/src/files-regular/refs-tests.js +++ b/src/files-regular/refs-tests.js @@ -1,8 +1,9 @@ /* eslint-env mocha */ 'use strict' -const map = require('async/map') +const mapSeries = require('async/mapSeries') const { getDescribe, getIt, expect } = require('../utils/mocha') +const loadFixture = require('aegir/fixtures') module.exports = (createCommon, suiteName, ipfsRefs, options) => { const describe = getDescribe(options) @@ -125,20 +126,20 @@ function getMockObjects () { return { animals: { land: { - 'african.txt': ['elephant', 'rhinocerous'], - 'americas.txt': ['ñandu', 'tapir'], - 'australian.txt': ['emu', 'kangaroo'] + 'african.txt': loadFixture('test/fixtures/refs-test/animals/land/african.txt', 'interface-ipfs-core'), + 'americas.txt': loadFixture('test/fixtures/refs-test/animals/land/americas.txt', 'interface-ipfs-core'), + 'australian.txt': loadFixture('test/fixtures/refs-test/animals/land/australian.txt', 'interface-ipfs-core') }, sea: { - 'atlantic.txt': ['dolphin', 'whale'], - 'indian.txt': ['cuttlefish', 'octopus'] + 'atlantic.txt': loadFixture('test/fixtures/refs-test/animals/sea/atlantic.txt', 'interface-ipfs-core'), + 'indian.txt': loadFixture('test/fixtures/refs-test/animals/sea/indian.txt', 'interface-ipfs-core') } }, fruits: { - 'tropical.txt': ['banana', 'pineapple'] + 'tropical.txt': loadFixture('test/fixtures/refs-test/fruits/tropical.txt', 'interface-ipfs-core') }, - 'atlantic-animals': ['dolphin', 'whale'], - 'mushroom.txt': ['mushroom'] + 'atlantic-animals': loadFixture('test/fixtures/refs-test/atlantic-animals', 'interface-ipfs-core'), + 'mushroom.txt': loadFixture('test/fixtures/refs-test/mushroom.txt', 'interface-ipfs-core') } } @@ -354,9 +355,9 @@ function loadPbContent (ipfs, node, callback) { function loadDagContent (ipfs, node, callback) { const store = { putData: (data, cb) => { - ipfs.add(Buffer.from(data), (err, res) => { + ipfs.add(data, (err, res) => { if (err) { - return callback(err) + return cb(err) } return cb(null, res[0].hash) }) @@ -373,14 +374,14 @@ function loadDagContent (ipfs, node, callback) { } function loadContent (ipfs, store, node, callback) { - if (Array.isArray(node)) { - return store.putData(node.join('\n'), callback) + if (Buffer.isBuffer(node)) { + return store.putData(node, callback) } if (typeof node === 'object') { const entries = Object.entries(node) const sorted = entries.sort((a, b) => a[0] > b[0] ? 1 : a[0] < b[0] ? -1 : 0) - map(sorted, ([name, child], cb) => { + mapSeries(sorted, ([name, child], cb) => { loadContent(ipfs, store, child, (err, cid) => { cb(err, { name, cid: cid && cid.toString() }) }) diff --git a/test/fixtures/refs-test/animals/land/african.txt b/test/fixtures/refs-test/animals/land/african.txt new file mode 100644 index 00000000..29decfcd --- /dev/null +++ b/test/fixtures/refs-test/animals/land/african.txt @@ -0,0 +1,2 @@ +elephant +rhinocerous \ No newline at end of file diff --git a/test/fixtures/refs-test/animals/land/americas.txt b/test/fixtures/refs-test/animals/land/americas.txt new file mode 100644 index 00000000..21368a87 --- /dev/null +++ b/test/fixtures/refs-test/animals/land/americas.txt @@ -0,0 +1,2 @@ +ñandu +tapir \ No newline at end of file diff --git a/test/fixtures/refs-test/animals/land/australian.txt b/test/fixtures/refs-test/animals/land/australian.txt new file mode 100644 index 00000000..a78c7bc9 --- /dev/null +++ b/test/fixtures/refs-test/animals/land/australian.txt @@ -0,0 +1,2 @@ +emu +kangaroo \ No newline at end of file diff --git a/test/fixtures/refs-test/animals/sea/atlantic.txt b/test/fixtures/refs-test/animals/sea/atlantic.txt new file mode 100644 index 00000000..f77ffe51 --- /dev/null +++ b/test/fixtures/refs-test/animals/sea/atlantic.txt @@ -0,0 +1,2 @@ +dolphin +whale \ No newline at end of file diff --git a/test/fixtures/refs-test/animals/sea/indian.txt b/test/fixtures/refs-test/animals/sea/indian.txt new file mode 100644 index 00000000..c455106f --- /dev/null +++ b/test/fixtures/refs-test/animals/sea/indian.txt @@ -0,0 +1,2 @@ +cuttlefish +octopus \ No newline at end of file diff --git a/test/fixtures/refs-test/atlantic-animals b/test/fixtures/refs-test/atlantic-animals new file mode 100644 index 00000000..f77ffe51 --- /dev/null +++ b/test/fixtures/refs-test/atlantic-animals @@ -0,0 +1,2 @@ +dolphin +whale \ No newline at end of file diff --git a/test/fixtures/refs-test/fruits/tropical.txt b/test/fixtures/refs-test/fruits/tropical.txt new file mode 100644 index 00000000..4f331bc7 --- /dev/null +++ b/test/fixtures/refs-test/fruits/tropical.txt @@ -0,0 +1,2 @@ +banana +pineapple \ No newline at end of file diff --git a/test/fixtures/refs-test/mushroom.txt b/test/fixtures/refs-test/mushroom.txt new file mode 100644 index 00000000..8b248aa9 --- /dev/null +++ b/test/fixtures/refs-test/mushroom.txt @@ -0,0 +1 @@ +mushroom \ No newline at end of file From 5338e39c48462538787580a49bd1e6b01e1717db Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 16 May 2019 16:00:07 +0100 Subject: [PATCH 2/3] chore: update contributors --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6fd4764b..b77f1377 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interface-ipfs-core", - "version": "0.101.0", + "version": "0.101.1", "description": "A test suite and interface you can use to implement a IPFS core interface.", "leadMaintainer": "Alan Shaw ", "main": "src/index.js", From 1b3d013b8b59abf51a1cad12a8b8a766d73ffd2e Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 16 May 2019 16:00:08 +0100 Subject: [PATCH 3/3] chore: release version v0.101.1 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7919f80f..b0a133df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [0.101.1](https://github.com/ipfs/interface-ipfs-core/compare/v0.101.0...v0.101.1) (2019-05-16) + + +### Bug Fixes + +* use fixtures for refs tests ([#471](https://github.com/ipfs/interface-ipfs-core/issues/471)) ([3f30830](https://github.com/ipfs/interface-ipfs-core/commit/3f30830)) + + + # [0.101.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.100.1...v0.101.0) (2019-05-15)