From c12a4914f6d7c873814e6b3255d4ea2986b3e267 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Sat, 21 Dec 2013 02:22:03 +0100 Subject: [PATCH] long name test --- test/extract.js | 37 ++++++++++++++++++++++++++++++++++++ test/fixtures/index.js | 1 + test/fixtures/long-name.tar | Bin 0 -> 2048 bytes test/pack.js | 23 ++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 test/fixtures/long-name.tar diff --git a/test/extract.js b/test/extract.js index 32dc6ad..91fe98b 100644 --- a/test/extract.js +++ b/test/extract.js @@ -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)); + }); \ No newline at end of file diff --git a/test/fixtures/index.js b/test/fixtures/index.js index 9658a5a..7e29b74 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -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'); diff --git a/test/fixtures/long-name.tar b/test/fixtures/long-name.tar new file mode 100644 index 0000000000000000000000000000000000000000..ae8c658d2b44d688f6d27cbff53e73b31079842a GIT binary patch literal 2048 zcmeH^O%8(~5QRMoC+G|m^gLr7iU~>snAo1asCySpOuAqe3_ovp%*T=#vSWBfw&Mzp zY2XMpgq~tgpI>I9=b0wHD*|6