forked from EvanOxfeld/node-unzip
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite extract to user duplexer2 to separate the events of the inbou…
…nd stream and outbound stream add tests for broken zipfiles
- Loading branch information
Showing
3 changed files
with
71 additions
and
37 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
var test = require('tap').test; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var temp = require('temp'); | ||
var unzip = require('../'); | ||
|
||
|
||
test("Parse a broken zipfile", function (t) { | ||
var archive = path.join(__dirname, '../testData/compressed-standard/broken.zip'); | ||
|
||
fs.createReadStream(archive) | ||
.pipe(unzip.Parse()) | ||
.on('entry', function(entry) { | ||
return entry.autodrain(); | ||
}) | ||
.promise() | ||
.catch(function(e) { | ||
t.same(e.message, 'FILE_ENDED'); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
|
||
test("extract a broken", function (t) { | ||
var archive = path.join(__dirname, '../testData/compressed-standard/broken.zip'); | ||
|
||
temp.mkdir('node-unzip-', function (err, dirPath) { | ||
if (err) { | ||
throw err; | ||
} | ||
var unzipExtractor = unzip.Extract({ path: dirPath }); | ||
|
||
fs.createReadStream(archive) | ||
.pipe(unzipExtractor) | ||
.promise() | ||
.catch(function(e) { | ||
t.same(e.message,'FILE_ENDED'); | ||
t.end(); | ||
}); | ||
}); | ||
}); |
Binary file not shown.