Browse files

[test] add test to cover fs.createReadStream.pipe(indexFile.createPar…

…serStream())
  • Loading branch information...
1 parent 198c37a commit b378cba9c18620ae9d0df76f6e61607c00e2ec25 @tmpvar tmpvar committed Nov 6, 2012
Showing with 25 additions and 1 deletion.
  1. +1 −0 test/fixtures/repo.js
  2. +24 −1 test/tests/pack-index.js
View
1 test/fixtures/repo.js
@@ -67,6 +67,7 @@ module.exports.getPackFile = function(fn) {
// cleanup
//rimraf(packRepoPath, function() {
fn(null, {
+ packFile: packFile,
totalObjects: count,
buffer: packFileBuffer,
indexBuffer: indexBuffer,
View
25 test/tests/pack-index.js
@@ -65,7 +65,30 @@ module.exports = {
t.end();
});
});
- }
+ },
+
+ "packfile index: parse stream (fs pipe)" : function(t) {
+ var ps = pack.createParserStream();
+ repo.getPackFile(function(err, packFile) {
+ t.plan(2 + packFile.verifyObjs.length * 2);
+
+ fs.createReadStream(packFile.packFile.replace('.pack', '.idx')).pipe(ps);
+
+ ps.on('end', function(result) {
+ t.ok(result.entries);
+
+ t.equal(packFile.verifyObjs.length, result.entries.length);
+
+ result.entries.forEach(function(entry) {
+ t.equal(entry.sha, packFile.verifyHash[entry.sha].sha);
+ t.equal(entry.offset, packFile.verifyHash[entry.sha].offset);
+ });
+
+ t.end();
+ });
+ });
+ },
+
// "unpack: valid object count (real file)" : function(t) {

0 comments on commit b378cba

Please sign in to comment.