Skip to content

Commit

Permalink
Add a test for npm-shrinkwrap crashes with empty dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
robertkowalski committed Apr 6, 2014
1 parent bf6a085 commit b027d32
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/tap/shrinkwrap-empty-deps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var test = require("tap").test
, npm = require("../../")
, mr = require("npm-registry-mock")
, common = require("../common-tap.js")
, path = require("path")
, fs = require("fs")
, osenv = require("osenv")
, rimraf = require("rimraf")
, pkg = __dirname + "/shrinkwrap-empty-deps"

test("returns a list of removed items", function (t) {
var desiredResultsPath = path.resolve(pkg, "npm-shrinkwrap.json")

cleanup()

mr(common.port, function (s) {
setup(function () {
npm.shrinkwrap([], function (err) {
if (err) return t.fail(err)
fs.readFile(desiredResultsPath, function (err, desired) {
if (err) return t.fail(err)
t.deepEqual({
"name": "npm-test-shrinkwrap-empty-deps",
"version": "0.0.0",
"dependencies": {}
}, JSON.parse(desired))
cleanup()
s.close()
t.end()
})
})
})
})
})

function setup (cb) {
cleanup()
process.chdir(pkg)
npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
cb()
})
}

function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(path.resolve(pkg, "npm-shrinkwrap.json"))
}
7 changes: 7 additions & 0 deletions test/tap/shrinkwrap-empty-deps/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"author": "Rockbert",
"name": "npm-test-shrinkwrap-empty-deps",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {}
}

0 comments on commit b027d32

Please sign in to comment.