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

added ipfs.ls test spec #150

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions tasks/daemons.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ function startDisposableDaemons (callback) {
throw err
}

ipfsNodes[key].startDaemon((err, ignore) => {
ipfsNodes[key].startDaemon((err, daemon) => {
if (err) {
throw err
}

daemon.add('test/test-folder', {r: true}, (e, r) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This folder is added too during the add tests, could you use the hash from there?

if (e) throw e
})
apiAddrs[key] = ipfsNodes[key].apiAddr
cb()
})
Expand Down
26 changes: 26 additions & 0 deletions test/api/ls.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'

describe('ls', function () {
it('should correctly retrieve links', function (done) {
apiClients['a'].ls('QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj', (err, res) => {
if (err === null && res !== undefined) {
assert(res.Objects[0].Links[0])
done()
}
})
})
it('should correctly handle a nonexisting hash', function (done) {
apiClients['a'].ls('surelynotavalidhashheh?', (err, res) => {
if (err !== null && res === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We since switched to expect, so you can do something like

expect(err).to.exist
expect(res).to.not.exist

done()
}
})
})
it('should correctly handle a nonexisting path', function (done) {
apiClients['a'].ls('QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj/folder_that_isnt_there', (err, res) => {
if (err !== null && res === undefined) {
done()
}
})
})
})