@@ -15,6 +15,7 @@ const Readable = require('readable-stream').Readable
1515const pull = require ( 'pull-stream' )
1616const concat = require ( 'concat-stream' )
1717const through = require ( 'through2' )
18+ const path = require ( 'path' )
1819const bl = require ( 'bl' )
1920
2021module . exports = ( common ) => {
@@ -129,6 +130,15 @@ module.exports = (common) => {
129130 } )
130131 } )
131132
133+ it ( 'add by path fails' , ( done ) => {
134+ const validPath = path . join ( process . cwd ( ) + '/package.json' )
135+
136+ ipfs . files . add ( validPath , ( err , res ) => {
137+ expect ( err ) . to . exist ( )
138+ done ( )
139+ } )
140+ } )
141+
132142 it ( 'a Readable Stream' , ( done ) => {
133143 const expectedCid = 'QmVv4Wz46JaZJeH5PMV4LGbRiiMKEmszPYY3g6fjGnVXBS'
134144
@@ -209,14 +219,14 @@ module.exports = (common) => {
209219 accumProgress += p
210220 }
211221
212- ipfs . files . add ( dirs , { progress : handler } , ( err , res ) => {
222+ ipfs . files . add ( dirs , { progress : handler } , ( err , filesAdded ) => {
213223 expect ( err ) . to . not . exist ( )
214- const root = res [ res . length - 1 ]
224+ const root = filesAdded [ filesAdded . length - 1 ]
215225
216- expect ( root . path ) . to . equal ( 'test-folder' )
217- expect ( root . hash ) . to . equal ( directory . cid )
218226 expect ( progCount ) . to . equal ( 8 )
219227 expect ( accumProgress ) . to . be . at . least ( total )
228+ expect ( root . path ) . to . equal ( 'test-folder' )
229+ expect ( root . hash ) . to . equal ( directory . cid )
220230 done ( )
221231 } )
222232 } )
@@ -729,6 +739,22 @@ module.exports = (common) => {
729739 done ( )
730740 } )
731741 } )
742+
743+ it ( 'should correctly handle a non existing hash' , ( done ) => {
744+ ipfs . ls ( 'surelynotavalidhashheh?' , ( err , res ) => {
745+ expect ( err ) . to . exist ( )
746+ expect ( res ) . to . not . exist ( )
747+ done ( )
748+ } )
749+ } )
750+
751+ it ( 'should correctly handle a non exiting path' , ( done ) => {
752+ ipfs . ls ( 'QmRNjDeKStKGTQXnJ2NFqeQ9oW/folder_that_isnt_there' , ( err , res ) => {
753+ expect ( err ) . to . exist ( )
754+ expect ( res ) . to . not . exist ( )
755+ done ( )
756+ } )
757+ } )
732758 } )
733759
734760 describe ( '.lsReadableStream' , ( ) => {
0 commit comments