From 7d9aca1807fcfd51ee3652b21d361aabcfeac7c9 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Wed, 25 Nov 2015 16:22:33 +0100 Subject: [PATCH 1/2] added ls test spec --- tasks/daemons.js | 6 ++++-- test/api/ls.spec.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 test/api/ls.spec.js diff --git a/tasks/daemons.js b/tasks/daemons.js index a688c6ab0..0312c229d 100644 --- a/tasks/daemons.js +++ b/tasks/daemons.js @@ -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) => { + if (e) throw e + }) apiAddrs[key] = ipfsNodes[key].apiAddr cb() }) diff --git a/test/api/ls.spec.js b/test/api/ls.spec.js new file mode 100644 index 000000000..27259ac2e --- /dev/null +++ b/test/api/ls.spec.js @@ -0,0 +1,19 @@ +'use strict' + +describe('ls', function () { + it('should correctly retrieve links', function (done) { + this.timeout(5000) + apiClients['a'].ls('QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj', (err, res) => { + if (err) { + throw err + } else done() + }) + }) + it('should correctly throw errors', function (done) { + apiClients['a'].ls('surelynotavalidhashheh?', (err, res) => { + if (err === undefined) { + throw new Error() + } else done() + }) + }) +}) From 6fe1f579238217f21fdd48af0987e6382502f0b3 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Thu, 26 Nov 2015 17:49:31 +0100 Subject: [PATCH 2/2] updated ls test spec --- test/api/ls.spec.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/api/ls.spec.js b/test/api/ls.spec.js index 27259ac2e..009594e15 100644 --- a/test/api/ls.spec.js +++ b/test/api/ls.spec.js @@ -2,18 +2,25 @@ describe('ls', function () { it('should correctly retrieve links', function (done) { - this.timeout(5000) apiClients['a'].ls('QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj', (err, res) => { - if (err) { - throw err - } else done() + if (err === null && res !== undefined) { + assert(res.Objects[0].Links[0]) + done() + } }) }) - it('should correctly throw errors', function (done) { + it('should correctly handle a nonexisting hash', function (done) { apiClients['a'].ls('surelynotavalidhashheh?', (err, res) => { - if (err === undefined) { - throw new Error() - } else done() + if (err !== null && res === undefined) { + 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() + } }) }) })