Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
clean: move test/http-api/extra/files.js to test/http-api/files.js
Browse files Browse the repository at this point in the history
  • Loading branch information
JonKrone committed Mar 15, 2018
1 parent 661c4bf commit f326ca9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 49 deletions.
2 changes: 1 addition & 1 deletion test/cli/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('files', () => runOnAndOff((thing) => {
.then(out => {
const hash = out.split(' ')[1]

// 'jsipfs object get <hash>' should time out with the daemon on
// 'jsipfs object get <hash>' should timeout with the daemon on
// and should fail fast with the daemon off
return Promise.race([
ipfs.fail(`object get ${hash}`),
Expand Down
30 changes: 0 additions & 30 deletions test/http-api/extra/files.js

This file was deleted.

18 changes: 0 additions & 18 deletions test/http-api/extra/version.js

This file was deleted.

42 changes: 42 additions & 0 deletions test/http-api/files.js
Original file line number Diff line number Diff line change
@@ -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))
])
})
})
})
})
5 changes: 5 additions & 0 deletions test/utils/ipfs-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f326ca9

Please sign in to comment.