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

Commit

Permalink
feat: additional tests for indirect pin.ls
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
  • Loading branch information
lidel committed Oct 21, 2018
1 parent 60c3c12 commit 2d4e86f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion js/src/pin/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = (createCommon, options) => {
parallel([
// two files wrapped in a directory, root CID pinned recursively
(cb) => {
const dir = fixtures.directory.files.map((file) => ({path: file.path, content: file.data}))
const dir = fixtures.directory.files.map((file) => ({ path: file.path, content: file.data }))
ipfs.files.add(dir, { pin: false }, (err, res) => {
if (err) return cb(err)
ipfs.pin.add(fixtures.directory.cid, { recursive: true }, cb)
Expand Down Expand Up @@ -90,6 +90,14 @@ module.exports = (createCommon, options) => {
type: 'recursive',
hash: fixtures.directory.cid
})
expect(pinset).to.deep.include({
type: 'indirect',
hash: fixtures.directory.files[0].cid
})
expect(pinset).to.deep.include({
type: 'indirect',
hash: fixtures.directory.files[1].cid
})
done()
})
})
Expand All @@ -112,6 +120,14 @@ module.exports = (createCommon, options) => {
type: 'direct',
hash: fixtures.files[1].cid
})
expect(pinset).to.deep.include({
type: 'indirect',
hash: fixtures.directory.files[0].cid
})
expect(pinset).to.deep.include({
type: 'indirect',
hash: fixtures.directory.files[1].cid
})
done()
})
})
Expand All @@ -134,12 +150,21 @@ module.exports = (createCommon, options) => {
type: 'direct',
hash: fixtures.files[1].cid
})
expect(pinset).to.deep.include({
type: 'indirect',
hash: fixtures.directory.files[0].cid
})
expect(pinset).to.deep.include({
type: 'indirect',
hash: fixtures.directory.files[1].cid
})
})
})

it('should list all direct pins', (done) => {
ipfs.pin.ls({ type: 'direct' }, (err, pinset) => {
expect(err).to.not.exist()
expect(pinset).to.have.lengthOf(1)
expect(pinset).to.deep.include({
type: 'direct',
hash: fixtures.files[1].cid
Expand Down

0 comments on commit 2d4e86f

Please sign in to comment.