Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit f440560

Browse files
authored
test: adds test for adding directories with --only-hash (#587)
Closes ipfs/js-ipfs#2684
1 parent 8b45ad0 commit f440560

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: src/add.js

+21
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,27 @@ module.exports = (common, options) => {
320320
.and.to.have.property('name').that.equals('TimeoutError')
321321
})
322322

323+
it('should add a directory with only-hash=true', async function () {
324+
this.slow(10 * 1000)
325+
const content = String(Math.random() + Date.now())
326+
327+
const files = await all(ipfs.add([{
328+
path: '/foo/bar.txt',
329+
content: Buffer.from(content)
330+
}, {
331+
path: '/foo/baz.txt',
332+
content: Buffer.from(content)
333+
}], { onlyHash: true }))
334+
expect(files).to.have.length(3)
335+
336+
await Promise.all(
337+
files.map(file => expect(ipfs.object.get(file.cid, { timeout: 4000 }))
338+
.to.eventually.be.rejected()
339+
.and.to.have.property('name').that.equals('TimeoutError')
340+
)
341+
)
342+
})
343+
323344
it('should add with mode as string', async function () {
324345
this.slow(10 * 1000)
325346
const mode = '0777'

0 commit comments

Comments
 (0)