From 93c80300279c6ddc4bcc6365a73c8e1336a4db72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Thu, 16 Feb 2017 16:44:55 -0800 Subject: [PATCH] test(manifest): removed extract-shrinkwrap test --- test/extract-stream.js | 23 ++++++++++ test/finalize-manifest.js | 14 ++++++ test/util.extract-shrinkwrap.js | 75 --------------------------------- 3 files changed, 37 insertions(+), 75 deletions(-) create mode 100644 test/extract-stream.js create mode 100644 test/finalize-manifest.js delete mode 100644 test/util.extract-shrinkwrap.js diff --git a/test/extract-stream.js b/test/extract-stream.js new file mode 100644 index 0000000..07183aa --- /dev/null +++ b/test/extract-stream.js @@ -0,0 +1,23 @@ +'use strict' + +var fs = require('fs') +var npmlog = require('npmlog') +var pipe = require('mississippi').pipe +var test = require('tap').test + +require('./util/test-dir')(__filename) + +var extractStream = require('../lib/extract-stream') + +npmlog.level = process.env.LOGLEVEL || 'silent' +var OPTS = { + log: npmlog +} + +test('basic extraction') +test('excludes symlinks') +test('renames .gitignore to .npmignore if not present') +test('accepts gid and uid opts') +test('accepts dmode/fmode/umask opts') +test('automatically handles gzipped tarballs') +test('strips first item in path, even if not `package/`') diff --git a/test/finalize-manifest.js b/test/finalize-manifest.js new file mode 100644 index 0000000..bd07551 --- /dev/null +++ b/test/finalize-manifest.js @@ -0,0 +1,14 @@ +'use strict' + +var test = require('tap').test + +require('./util/test-dir')(__filename) + +var finalizeManifest = require('../lib/finalize-manifest') + +test('returns a manifest with the right fields') +test('defaults all field to expected types + values') +test('manifest returned is immutable + inextensible') +test('fills in shrinkwrap if missing') +test('fills in shasum if missing') +test('fills in `bin` if `directories.bin` present') diff --git a/test/util.extract-shrinkwrap.js b/test/util.extract-shrinkwrap.js deleted file mode 100644 index 1a358ac..0000000 --- a/test/util.extract-shrinkwrap.js +++ /dev/null @@ -1,75 +0,0 @@ -'use strict' - -var fs = require('fs') -var npmlog = require('npmlog') -var pipe = require('mississippi').pipe -var test = require('tap').test - -require('./util/test-dir')(__filename) - -var extractShrinkwrap = require('../lib/util/extract-shrinkwrap') - -var SHRINKWRAP = { - 'name': 'test', - 'version': '1.0.0', - 'dependencies': { - 'eggplant': { - 'version': '1.0.2', - 'from': 'eggplant@latest', - 'resolved': 'https://registry.npmjs.org/eggplant/-/eggplant-1.0.2.tgz' - } - } -} - -var HAS_SHRINKWRAP = '../../fixtures/has-shrinkwrap.tgz' -var NO_SHRINKWRAP = '../../fixtures/no-shrinkwrap.tgz' -var DEST = './copy.tgz' - -test('basic shrinkwrap extraction', function (t) { - var input = fs.createReadStream(HAS_SHRINKWRAP) - var output = fs.createWriteStream(DEST) - - t.plan(3) - extractShrinkwrap(input, {log: npmlog}, function (err, sr) { - if (err) { throw err } - t.ok(sr, 'got a shrinkwrap back!') - t.deepEqual(sr, SHRINKWRAP, 'shrinkwrap data correct') - }) - pipe(input, output, function (err) { - if (err) { throw err } - fs.readFile(HAS_SHRINKWRAP, 'utf8', function (err, src) { - if (err) { throw err } - fs.readFile(DEST, 'utf8', function (err, dest) { - if (err) { throw err } - t.equal(src, dest, 'data fully copied') - }) - }) - }) -}) - -test('no shrinkwrap in tarball', function (t) { - var input = fs.createReadStream(NO_SHRINKWRAP) - var output = fs.createWriteStream(DEST) - - t.plan(2) - extractShrinkwrap(input, {log: npmlog}, function (err, sr) { - if (err) { throw err } - t.notOk(sr, 'no shrinkwrap returned') - }) - pipe(input, output, function (err) { - if (err) { throw err } - fs.readFile(NO_SHRINKWRAP, 'utf8', function (err, src) { - if (err) { throw err } - fs.readFile(DEST, 'utf8', function (err, dest) { - if (err) { throw err } - t.equal(src, dest, 'data fully copied') - }) - }) - }) -}) - -test('stops parsing tarball after shrinkwrap found') -test('source stream continues after shrinkwrap found') -test('source stream errors trigger extract error') -test('only calls cb once if stream error after shrinkwrap found') -test('works fine when teeing a `request` stream')