Last active
December 15, 2015 02:19
-
-
Save EvanOxfeld/5186611 to your computer and use it in GitHub Desktop.
Attempt at a reduced test case for EvanOxfeld/node-unzip#20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var test = require('tap').test; | |
var PassThrough = require('stream').PassThrough; | |
var path = require('path') | |
var fs = require('fs'); | |
var zlib = require('zlib'); | |
var PullStream = require('pullstream'); | |
var loremString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing el' + | |
'it. Morbi faucibus, purus at gravida dictum, libero arcu convallis la' + | |
'cus, in commodo libero metus eu nisi. Nullam commodo, neque nec porta' + | |
' placerat, nisi est fermentum augue, vitae gravida tellus sapien sit ' + | |
'amet tellus. Aenean non diam orci. Proin quis elit turpis. Suspendiss' + | |
'e non diam ipsum. Suspendisse nec ullamcorper odio. Vestibulum arcu m' + | |
'i, sodales non suscipit id, ultrices ut massa. Sed ac sem sit amet ar' + | |
'cu malesuada fermentum. Nunc sed. '; | |
test('write greater than highWaterMark to zlib inflateRaw stream', function(t) { | |
var deflater = zlib.createDeflateRaw(); | |
deflater | |
.pipe(fs.createWriteStream(path.join(__dirname, 'test.in'))) | |
.once('close', function() { | |
var loremCompressed = fs.readFileSync(path.join(__dirname, 'test.in')); | |
var ps = new PullStream(); | |
ps.write(loremCompressed); | |
ps.write(loremCompressed); | |
ps.end(); | |
runTest(ps, function() { | |
runTest(ps, function() { | |
t.end(); | |
}); | |
}); | |
}); | |
deflater.write(loremString); | |
deflater.end(); | |
function runTest(ps, callback) { | |
ps | |
.pipe(288, zlib.createInflateRaw({ | |
chunkSize: 64, | |
highWaterMark: 2 | |
})) | |
.pipe(new PassThrough()) | |
.pipe(fs.createWriteStream(path.join(__dirname, 'test.out'))) | |
.on('close', function() { | |
var file = fs.readFileSync(path.join(__dirname, 'test.out')); | |
t.equal(file.toString(), loremString); | |
callback(); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added pullstream to the test case. Unfortunately, still doesn't recreate EvanOxfeld/node-unzip#20