@@ -15,6 +15,7 @@ const Readable = require('readable-stream').Readable
15
15
const pull = require ( 'pull-stream' )
16
16
const concat = require ( 'concat-stream' )
17
17
const through = require ( 'through2' )
18
+ const path = require ( 'path' )
18
19
const bl = require ( 'bl' )
19
20
20
21
module . exports = ( common ) => {
@@ -129,6 +130,15 @@ module.exports = (common) => {
129
130
} )
130
131
} )
131
132
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
+
132
142
it ( 'a Readable Stream' , ( done ) => {
133
143
const expectedCid = 'QmVv4Wz46JaZJeH5PMV4LGbRiiMKEmszPYY3g6fjGnVXBS'
134
144
@@ -209,14 +219,14 @@ module.exports = (common) => {
209
219
accumProgress += p
210
220
}
211
221
212
- ipfs . files . add ( dirs , { progress : handler } , ( err , res ) => {
222
+ ipfs . files . add ( dirs , { progress : handler } , ( err , filesAdded ) => {
213
223
expect ( err ) . to . not . exist ( )
214
- const root = res [ res . length - 1 ]
224
+ const root = filesAdded [ filesAdded . length - 1 ]
215
225
216
- expect ( root . path ) . to . equal ( 'test-folder' )
217
- expect ( root . hash ) . to . equal ( directory . cid )
218
226
expect ( progCount ) . to . equal ( 8 )
219
227
expect ( accumProgress ) . to . be . at . least ( total )
228
+ expect ( root . path ) . to . equal ( 'test-folder' )
229
+ expect ( root . hash ) . to . equal ( directory . cid )
220
230
done ( )
221
231
} )
222
232
} )
@@ -729,6 +739,22 @@ module.exports = (common) => {
729
739
done ( )
730
740
} )
731
741
} )
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
+ } )
732
758
} )
733
759
734
760
describe ( '.lsReadableStream' , ( ) => {
0 commit comments