diff --git a/test/cli/files.js b/test/cli/files.js index a034424647..2e9fec39b5 100644 --- a/test/cli/files.js +++ b/test/cli/files.js @@ -290,7 +290,7 @@ describe('files', () => runOnAndOff((thing) => { .then(out => { const hash = out.split(' ')[1] - // 'jsipfs object get ' should time out with the daemon on + // 'jsipfs object get ' should timeout with the daemon on // and should fail fast with the daemon off return Promise.race([ ipfs.fail(`object get ${hash}`), diff --git a/test/http-api/extra/files.js b/test/http-api/extra/files.js deleted file mode 100644 index 1e94114184..0000000000 --- a/test/http-api/extra/files.js +++ /dev/null @@ -1,30 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const chai = require('chai') -const dirtyChai = require('dirty-chai') -chai.use(dirtyChai) - -module.exports = ctl => { - describe('.files', () => { - describe('.add', function () { - it('performs a speculative add, --only-hash', () => { - const content = String(Math.random() + Date.now()) - - return ctl.add(Buffer.from(content), { onlyHash: true }) - .then(files => { - const getAttempt = ctl.object.get(files[0].hash) - .then(() => { - throw new Error('Should not find an object for content added with --only-hash') - }) - - return Promise.race([ - getAttempt, - new Promise((resolve, reject) => setTimeout(resolve, 4000)) - ]) - }) - }) - }) - }) -} diff --git a/test/http-api/extra/version.js b/test/http-api/extra/version.js deleted file mode 100644 index 514f74d48b..0000000000 --- a/test/http-api/extra/version.js +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-env mocha */ -'use strict' - -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - -module.exports = ctl => { - describe('.version', () => { - it('gets the version', () => - ctl.version().then(result => { - expect(result).to.have.a.property('version') - expect(result).to.have.a.property('commit') - expect(result).to.have.a.property('repo') - })) - }) -} diff --git a/test/http-api/files.js b/test/http-api/files.js new file mode 100644 index 0000000000..4e2f297d70 --- /dev/null +++ b/test/http-api/files.js @@ -0,0 +1,42 @@ +/* eslint-env mocha */ +/* eslint max-nested-callbacks: ["error", 8] */ +'use strict' + +const chai = require('chai') +const dirtyChai = require('dirty-chai') +chai.use(dirtyChai) + +describe('.files', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) + }) + + after((done) => ipfsd.stop(done)) + + describe('.add', function () { + it('performs a speculative add, --only-hash', () => { + const content = String(Math.random()) + + return ipfs.add(Buffer.from(content), { onlyHash: true }) + .then(files => { + const getAttempt = ipfs.object.get(files[0].hash) + .then(() => { + throw new Error('Should not find an object for content added with --only-hash') + }) + + return Promise.race([ + getAttempt, + new Promise((resolve, reject) => setTimeout(resolve, 4000)) + ]) + }) + }) + }) +}) diff --git a/test/utils/ipfs-exec.js b/test/utils/ipfs-exec.js index 116d67c9b9..2437f136a9 100644 --- a/test/utils/ipfs-exec.js +++ b/test/utils/ipfs-exec.js @@ -51,6 +51,11 @@ module.exports = (repoPath, opts) => { return res } + /** + * Expect the command passed as @param arguments to fail. + * @return {Promise} Resolves if the command passed as @param arguments fails, + * rejects if it was successful. + */ ipfs.fail = function ipfsFail () { let args = Array.from(arguments) let caught = false