From ce1110d961cd6d2641e325d13fc5f1a5efe8adf8 Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Tue, 12 Dec 2017 09:29:28 +0000 Subject: [PATCH 1/2] fix: tests cat unknown file and dir errors --- src/files.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/files.js b/src/files.js index cfa727ad2..003a742f8 100644 --- a/src/files.js +++ b/src/files.js @@ -431,6 +431,31 @@ module.exports = (common) => { } }) }) + + it.only('errors on unknown path', () => { + return ipfs.files.cat(smallFile.cid + '/does-not-exist') + .catch((err) => { + expect(err).to.exist() + expect(err.message).to.contain('No such file') + }) + }) + + it.only('errors on dir path', () => { + const file = { path: 'dir/testfile.txt', content: smallFile.data } + + return ipfs.files.add([file]) + .then((filesAdded) => { + expect(filesAdded.length).to.equal(2) + const files = filesAdded.filter((file) => file.path === 'dir') + expect(files.length).to.equal(1) + const dir = files[0] + return ipfs.files.cat(dir.hash) + .catch((err) => { + expect(err).to.exist() + expect(err.message).to.contain('this dag node is a directory') + }) + }) + }) }) describe('.catReadableStream', () => { From 67711050bc45f09cd7f505bcf6870b942551b04e Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Tue, 12 Dec 2017 11:39:22 +0000 Subject: [PATCH 2/2] removed only --- src/files.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/files.js b/src/files.js index 003a742f8..27964a348 100644 --- a/src/files.js +++ b/src/files.js @@ -432,7 +432,7 @@ module.exports = (common) => { }) }) - it.only('errors on unknown path', () => { + it('errors on unknown path', () => { return ipfs.files.cat(smallFile.cid + '/does-not-exist') .catch((err) => { expect(err).to.exist() @@ -440,7 +440,7 @@ module.exports = (common) => { }) }) - it.only('errors on dir path', () => { + it('errors on dir path', () => { const file = { path: 'dir/testfile.txt', content: smallFile.data } return ipfs.files.add([file])