22/* eslint max-nested-callbacks: ["error", 8] */
33'use strict'
44
5+ const hat = require ( 'hat' )
56const chai = require ( 'chai' )
67const dirtyChai = require ( 'dirty-chai' )
78const DaemonFactory = require ( 'ipfsd-ctl' )
@@ -34,7 +35,7 @@ describe('.files', () => {
3435
3536 describe ( '.add' , function ( ) {
3637 it ( 'performs a speculative add, --only-hash' , ( ) => {
37- const content = String ( Math . random ( ) )
38+ const content = hat ( )
3839
3940 return ipfs . add ( Buffer . from ( content ) , { onlyHash : true } )
4041 . then ( files => {
@@ -60,7 +61,7 @@ describe('.files', () => {
6061 } )
6162
6263 it ( 'lists files' , ( ) => {
63- const fileName = `single-file-${ Math . random ( ) } .txt`
64+ const fileName = `single-file-${ hat ( ) } .txt`
6465
6566 return ipfs . files . write ( `/${ fileName } ` , Buffer . from ( 'Hello world' ) , {
6667 create : true
@@ -73,8 +74,8 @@ describe('.files', () => {
7374 } )
7475
7576 it ( 'lists files in directories' , ( ) => {
76- const dirName = `dir-${ Math . random ( ) } `
77- const fileName = `file-in-dir-${ Math . random ( ) } .txt`
77+ const dirName = `dir-${ hat ( ) } `
78+ const fileName = `file-in-dir-${ hat ( ) } .txt`
7879
7980 return ipfs . files . write ( `/${ dirName } /${ fileName } ` , Buffer . from ( 'Hello world' ) , {
8081 create : true ,
@@ -90,8 +91,8 @@ describe('.files', () => {
9091
9192 describe ( '.cp' , function ( ) {
9293 it ( 'copies a file' , ( ) => {
93- const source = `source-file-${ Math . random ( ) } .txt`
94- const destination = `destination-file-${ Math . random ( ) } .txt`
94+ const source = `source-file-${ hat ( ) } .txt`
95+ const destination = `destination-file-${ hat ( ) } .txt`
9596
9697 return ipfs . files . write ( `/${ source } ` , Buffer . from ( 'Hello world' ) , {
9798 create : true
@@ -116,8 +117,8 @@ describe('.files', () => {
116117 } )
117118
118119 it ( 'copies a directory' , ( ) => {
119- const source = `source-dir-${ Math . random ( ) } `
120- const destination = `destination-dir-${ Math . random ( ) } `
120+ const source = `source-dir-${ hat ( ) } `
121+ const destination = `destination-dir-${ hat ( ) } `
121122
122123 return ipfs . files . mkdir ( `/${ source } ` )
123124 . then ( ( ) => ipfs . files . cp ( `/${ source } ` , `/${ destination } ` ) )
@@ -140,8 +141,8 @@ describe('.files', () => {
140141 } )
141142
142143 it ( 'copies a file with array args' , ( ) => {
143- const source = `source-file-${ Math . random ( ) } .txt`
144- const destination = `destination-file-${ Math . random ( ) } .txt`
144+ const source = `source-file-${ hat ( ) } .txt`
145+ const destination = `destination-file-${ hat ( ) } .txt`
145146
146147 return ipfs . files . write ( `/${ source } ` , Buffer . from ( 'Hello world' ) , {
147148 create : true
@@ -166,8 +167,8 @@ describe('.files', () => {
166167 } )
167168
168169 it ( 'copies a directory with array args' , ( ) => {
169- const source = `source-dir-${ Math . random ( ) } `
170- const destination = `destination-dir-${ Math . random ( ) } `
170+ const source = `source-dir-${ hat ( ) } `
171+ const destination = `destination-dir-${ hat ( ) } `
171172
172173 return ipfs . files . mkdir ( `/${ source } ` )
173174 . then ( ( ) => ipfs . files . cp ( [ `/${ source } ` , `/${ destination } ` ] ) )
@@ -192,7 +193,7 @@ describe('.files', () => {
192193
193194 describe ( '.mkdir' , function ( ) {
194195 it ( 'makes a directory' , ( ) => {
195- const directory = `directory-${ Math . random ( ) } `
196+ const directory = `directory-${ hat ( ) } `
196197
197198 return ipfs . files . mkdir ( `/${ directory } ` )
198199 . then ( ( ) => ipfs . files . ls ( `/` , {
@@ -210,8 +211,8 @@ describe('.files', () => {
210211
211212 describe ( '.mv' , function ( ) {
212213 it ( 'moves a file' , ( ) => {
213- const source = `source-file-${ Math . random ( ) } .txt`
214- const destination = `destination-file-${ Math . random ( ) } .txt`
214+ const source = `source-file-${ hat ( ) } .txt`
215+ const destination = `destination-file-${ hat ( ) } .txt`
215216
216217 return ipfs . files . write ( `/${ source } ` , Buffer . from ( 'Hello world' ) , {
217218 create : true
@@ -234,8 +235,8 @@ describe('.files', () => {
234235 } )
235236
236237 it ( 'moves a directory' , ( ) => {
237- const source = `source-dir-${ Math . random ( ) } `
238- const destination = `destination-dir-${ Math . random ( ) } `
238+ const source = `source-dir-${ hat ( ) } `
239+ const destination = `destination-dir-${ hat ( ) } `
239240
240241 return ipfs . files . mkdir ( `/${ source } ` )
241242 . then ( ( ) => ipfs . files . mv ( `/${ source } ` , `/${ destination } ` ) )
@@ -258,8 +259,8 @@ describe('.files', () => {
258259 } )
259260
260261 it ( 'moves a file with array args' , ( ) => {
261- const source = `source-file-${ Math . random ( ) } .txt`
262- const destination = `destination-file-${ Math . random ( ) } .txt`
262+ const source = `source-file-${ hat ( ) } .txt`
263+ const destination = `destination-file-${ hat ( ) } .txt`
263264
264265 return ipfs . files . write ( `/${ source } ` , Buffer . from ( 'Hello world' ) , {
265266 create : true
@@ -282,8 +283,8 @@ describe('.files', () => {
282283 } )
283284
284285 it ( 'moves a directory with array args' , ( ) => {
285- const source = `source-dir-${ Math . random ( ) } `
286- const destination = `destination-dir-${ Math . random ( ) } `
286+ const source = `source-dir-${ hat ( ) } `
287+ const destination = `destination-dir-${ hat ( ) } `
287288
288289 return ipfs . files . mkdir ( `/${ source } ` )
289290 . then ( ( ) => ipfs . files . mv ( [ `/${ source } ` , `/${ destination } ` ] ) )
@@ -308,7 +309,7 @@ describe('.files', () => {
308309
309310 describe ( '.read' , function ( ) {
310311 it ( 'reads a file' , ( ) => {
311- const fileName = `single-file-${ Math . random ( ) } .txt`
312+ const fileName = `single-file-${ hat ( ) } .txt`
312313 const content = Buffer . from ( 'Hello world' )
313314
314315 return ipfs . files . write ( `/${ fileName } ` , content , {
@@ -323,7 +324,7 @@ describe('.files', () => {
323324
324325 describe ( '.rm' , function ( ) {
325326 it ( 'removes a file' , ( ) => {
326- const fileName = `single-file-${ Math . random ( ) } .txt`
327+ const fileName = `single-file-${ hat ( ) } .txt`
327328
328329 return ipfs . files . write ( `/${ fileName } ` , Buffer . from ( 'Hello world' ) , {
329330 create : true
@@ -340,8 +341,8 @@ describe('.files', () => {
340341 } )
341342
342343 it ( 'removes a directory' , ( ) => {
343- const dirName = `dir-${ Math . random ( ) } `
344- const fileName = `file-in-dir-${ Math . random ( ) } .txt`
344+ const dirName = `dir-${ hat ( ) } `
345+ const fileName = `file-in-dir-${ hat ( ) } .txt`
345346
346347 return ipfs . files . write ( `/${ dirName } /${ fileName } ` , Buffer . from ( 'Hello world' ) , {
347348 create : true ,
@@ -363,7 +364,7 @@ describe('.files', () => {
363364
364365 describe ( '.stat' , function ( ) {
365366 it ( 'stats a file' , ( ) => {
366- const fileName = `single-file-${ Math . random ( ) } .txt`
367+ const fileName = `single-file-${ hat ( ) } .txt`
367368
368369 return ipfs . files . write ( `/${ fileName } ` , Buffer . from ( 'Hello world' ) , {
369370 create : true
@@ -384,7 +385,7 @@ describe('.files', () => {
384385 } )
385386
386387 it ( 'stats a directory' , ( ) => {
387- const dirName = `dir-${ Math . random ( ) } `
388+ const dirName = `dir-${ hat ( ) } `
388389
389390 return ipfs . files . mkdir ( `/${ dirName } ` )
390391 . then ( ( ) => ipfs . files . stat ( `/${ dirName } ` ) )
0 commit comments