Skip to content

Commit

Permalink
[test] add test to cover fs.createReadStream.pipe(indexFile.createPar…
Browse files Browse the repository at this point in the history
…serStream())
  • Loading branch information
tmpvar committed Nov 7, 2012
1 parent 198c37a commit b378cba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/fixtures/repo.js
Expand Up @@ -67,6 +67,7 @@ module.exports.getPackFile = function(fn) {
// cleanup
//rimraf(packRepoPath, function() {
fn(null, {
packFile: packFile,
totalObjects: count,
buffer: packFileBuffer,
indexBuffer: indexBuffer,
Expand Down
25 changes: 24 additions & 1 deletion test/tests/pack-index.js
Expand Up @@ -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) {
Expand Down

0 comments on commit b378cba

Please sign in to comment.