long name test

This commit is contained in:
Mathias Buus 2013-12-21 02:22:03 +01:00
parent 585cf8c55f
commit c12a4914f6
4 changed files with 61 additions and 0 deletions

View file

@ -265,4 +265,41 @@ test('types', function(t) {
});
extract.end(fs.readFileSync(fixtures.TYPES_TAR));
});
test('long-name', function(t) {
t.plan(3);
var extract = tar.extract();
var noEntries = false;
extract.on('entry', function(header, stream, callback) {
t.deepEqual(header, {
name: 'my/file/is/longer/than/100/characters/and/should/use/the/prefix/header/foobarbaz/foobarbaz/foobarbaz/foobarbaz/foobarbaz/foobarbaz/filename.txt',
mode: 0644,
uid: 501,
gid: 20,
size: 15,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
uname: 'maf',
gname: 'staff',
devmajor: 0,
devminor: 0
});
stream.pipe(concat(function(data) {
noEntries = true;
t.same(data.toString(), 'hello long name');
callback();
}));
});
extract.on('finish', function() {
t.ok(noEntries);
});
extract.end(fs.readFileSync(fixtures.LONG_NAME_TAR));
});

View file

@ -3,3 +3,4 @@ var path = require('path');
exports.ONE_FILE_TAR = path.join(__dirname, 'one-file.tar');
exports.MULTI_FILE_TAR = path.join(__dirname, 'multi-file.tar');
exports.TYPES_TAR = path.join(__dirname, 'types.tar');
exports.LONG_NAME_TAR = path.join(__dirname, 'long-name.tar');

BIN
test/fixtures/long-name.tar vendored Normal file

Binary file not shown.

View file

@ -95,4 +95,27 @@ test('types', function(t) {
t.deepEqual(data, fs.readFileSync(fixtures.TYPES_TAR));
}));
});
test('long-name', function(t) {
t.plan(2);
var pack = tar.pack();
pack.entry({
name:'my/file/is/longer/than/100/characters/and/should/use/the/prefix/header/foobarbaz/foobarbaz/foobarbaz/foobarbaz/foobarbaz/foobarbaz/filename.txt',
mtime:new Date(1387580181000),
type:'file',
mode:0644,
uname:'maf',
gname:'staff',
uid:501,
gid:20
}, 'hello long name');
pack.finalize();
pack.pipe(concat(function(data) {
t.equal(data.length & 511, 0);
t.deepEqual(data, fs.readFileSync(fixtures.LONG_NAME_TAR));
}));
});