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)
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",
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