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

test: add meta for ipfs.get tests #589

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,27 @@ module.exports = (common, options) => {
break
}
})

it('should get file with mode', async () => {
const mode = 0o777
const content = String(Math.random() + Date.now())
const [{ cid }] = await all(ipfs.add({ content, mode }))

const res = await all(ipfs.get(cid))

expect(res).to.have.length(1)
expect(res[0]).to.have.property('mode').that.equals(mode)
})

it('should get file with mtime', async () => {
const mtime = { secs: Math.floor((Date.now() - (Math.random() * 1000)) / 1000) }
const content = String(Math.random() + Date.now())
const [{ cid }] = await all(ipfs.add({ content, mtime }))

const res = await all(ipfs.get(cid))

expect(res).to.have.length(1)
expect(res).to.have.nested.property('0.mtime.secs').that.deep.equals(mtime.secs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an extra test where the mtime passed to ipfs.add contains a fractional nanosecond and asserts that nsecs is generated properly.

})
})
}