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

test: adds test for adding directories with --only-hash #587

Merged
merged 1 commit into from
Feb 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,27 @@ module.exports = (common, options) => {
.and.to.have.property('name').that.equals('TimeoutError')
})

it('should add a directory with only-hash=true', async function () {
this.slow(10 * 1000)
const content = String(Math.random() + Date.now())

const files = await all(ipfs.add([{
path: '/foo/bar.txt',
content: Buffer.from(content)
}, {
path: '/foo/baz.txt',
content: Buffer.from(content)
}], { onlyHash: true }))
expect(files).to.have.length(3)

await Promise.all(
files.map(file => expect(ipfs.object.get(file.cid, { timeout: 4000 }))
.to.eventually.be.rejected()
.and.to.have.property('name').that.equals('TimeoutError')
)
)
})

it('should add with mode as string', async function () {
this.slow(10 * 1000)
const mode = '0777'
Expand Down