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

Commit f326ca9

Browse files
committed
clean: move test/http-api/extra/files.js to test/http-api/files.js
1 parent 661c4bf commit f326ca9

File tree

5 files changed

+48
-49
lines changed

5 files changed

+48
-49
lines changed

test/cli/files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ describe('files', () => runOnAndOff((thing) => {
290290
.then(out => {
291291
const hash = out.split(' ')[1]
292292

293-
// 'jsipfs object get <hash>' should time out with the daemon on
293+
// 'jsipfs object get <hash>' should timeout with the daemon on
294294
// and should fail fast with the daemon off
295295
return Promise.race([
296296
ipfs.fail(`object get ${hash}`),

test/http-api/extra/files.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

test/http-api/extra/version.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/http-api/files.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* eslint-env mocha */
2+
/* eslint max-nested-callbacks: ["error", 8] */
3+
'use strict'
4+
5+
const chai = require('chai')
6+
const dirtyChai = require('dirty-chai')
7+
chai.use(dirtyChai)
8+
9+
describe('.files', () => {
10+
let ipfs = null
11+
let ipfsd = null
12+
before(function (done) {
13+
this.timeout(20 * 1000)
14+
df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => {
15+
expect(err).to.not.exist()
16+
ipfsd = _ipfsd
17+
ipfs = ipfsd.api
18+
done()
19+
})
20+
})
21+
22+
after((done) => ipfsd.stop(done))
23+
24+
describe('.add', function () {
25+
it('performs a speculative add, --only-hash', () => {
26+
const content = String(Math.random())
27+
28+
return ipfs.add(Buffer.from(content), { onlyHash: true })
29+
.then(files => {
30+
const getAttempt = ipfs.object.get(files[0].hash)
31+
.then(() => {
32+
throw new Error('Should not find an object for content added with --only-hash')
33+
})
34+
35+
return Promise.race([
36+
getAttempt,
37+
new Promise((resolve, reject) => setTimeout(resolve, 4000))
38+
])
39+
})
40+
})
41+
})
42+
})

test/utils/ipfs-exec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ module.exports = (repoPath, opts) => {
5151
return res
5252
}
5353

54+
/**
55+
* Expect the command passed as @param arguments to fail.
56+
* @return {Promise} Resolves if the command passed as @param arguments fails,
57+
* rejects if it was successful.
58+
*/
5459
ipfs.fail = function ipfsFail () {
5560
let args = Array.from(arguments)
5661
let caught = false

0 commit comments

Comments
 (0)