File tree Expand file tree Collapse file tree 2 files changed +10
-23
lines changed Expand file tree Collapse file tree 2 files changed +10
-23
lines changed Original file line number Diff line number Diff line change 1414 "scripts" : {
1515 "prepare" : " mkdir -p dist && browserify -s unbzip2Stream index.js | uglifyjs > dist/unbzip2-stream.min.js" ,
1616 "browser-test" : " browserify -t brfs test/simple.js | tape-run" ,
17- "prepare-long-test" : " dd if= /dev/urandom of=test/fixtures/vmlinux.bin bs=50x1024x1024 count=2 && cat test/fixtures/vmlinux.bin | bzip2 > test/fixtures/vmlinux.bin.bz2" ,
17+ "prepare-long-test" : " head -c 104857600 < /dev/urandom | tee test/fixtures/vmlinux.bin | bzip2 > test/fixtures/vmlinux.bin.bz2" ,
1818 "long-test" : " tape test/extra/long.js" ,
1919 "download-test" : " beefy test/browser/long.js --open -- -t brfs" ,
2020 "test" : " tape test/*.js"
3838 "brfs" : " ^1.2.0" ,
3939 "browserify" : " ^8.1.0" ,
4040 "concat-stream" : " ^1.4.7" ,
41+ "stream-equal" : " ^1.1.1" ,
4142 "tape" : " ^3.4.0" ,
4243 "tape-run" : " ^4.0.0" ,
43- "throughout" : " 0.0.0" ,
4444 "uglify-js" : " ^3.0.10"
4545 },
4646 "dependencies" : {
Original file line number Diff line number Diff line change 11var unbzip2Stream = require ( '../..' ) ;
22var test = require ( 'tape' ) ;
3- var through = require ( 'through' ) ;
4- var throughout = require ( 'throughout' ) ;
53var fs = require ( 'fs' ) ;
4+ var streamEqual = require ( 'stream-equal' ) ;
65
76test ( 'a very large binary file piped into unbzip2-stream results in original file content' , function ( t ) {
8- t . plan ( 2 ) ;
7+ t . plan ( 1 ) ;
98 var source = fs . createReadStream ( 'test/fixtures/vmlinux.bin.bz2' ) ;
9+ var expected = fs . createReadStream ( 'test/fixtures/vmlinux.bin' ) ;
1010 var unbz2 = unbzip2Stream ( ) ;
11- var received = 0 ;
12- var buffers = [ ] ;
13-
14- unbz2 . on ( 'error' , function ( err ) {
15- console . log ( err ) ;
16- //t.notOk(err.message);
11+ source . pipe ( unbz2 ) ;
12+ streamEqual ( expected , unbz2 , function ( err , equal ) {
13+ if ( err )
14+ t . ok ( false , err ) ;
15+ t . ok ( equal , "same file contents" ) ;
1716 } ) ;
18-
19- var sink = through ( function write ( data ) {
20- received += data . length ;
21- buffers . push ( data ) ;
22- } , function end ( ) {
23- var expected = fs . readFileSync ( 'test/fixtures/vmlinux.bin' ) ;
24- t . equal ( received , expected . length ) ;
25- t . deepEqual ( Buffer . concat ( buffers ) , expected ) ;
26- this . queue ( null ) ;
27- } ) ;
28- source . pipe ( throughout ( unbz2 , sink ) ) ;
2917} ) ;
30-
You can’t perform that action at this time.
0 commit comments