Skip to content

Commit

Permalink
test: use dedicated cache for mocked packages
Browse files Browse the repository at this point in the history
  • Loading branch information
robertkowalski committed Nov 14, 2013
1 parent 9ba9467 commit 1e78d55
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
7 changes: 7 additions & 0 deletions test/tap/noargs-install-config-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pkg += path.sep + "noargs-install-config-save"
function writePackageJson() {
rimraf.sync(pkg)
mkdirp.sync(pkg)
mkdirp.sync(pkg + "/cache")

fs.writeFileSync(pkg + "/package.json", JSON.stringify({
"author": "Rocko Artischocko",
Expand All @@ -34,6 +35,7 @@ function createChild (args) {
var env = {
npm_config_save: true,
npm_config_registry: common.registry,
npm_config_cache: pkg + "/cache",
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH
Expand Down Expand Up @@ -78,3 +80,8 @@ test("updates the package.json (adds dependencies) with an argument", function (
})
})
})

test("cleanup", function (t) {
rimraf.sync(pkg + "/cache")
t.end()
})
12 changes: 9 additions & 3 deletions test/tap/outdated-include-devdependencies.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
var common = require("../common-tap.js")
var test = require("tap").test
var npm = require("../../")

var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var mr = require("npm-registry-mock")

// config
var pkg = __dirname + '/outdated-include-devdependencies'

mkdirp.sync(pkg + "/cache")

test("includes devDependencies in outdated", function (t) {
process.chdir(pkg)
mr(common.port, function (s) {
npm.load({registry: common.registry}, function () {
npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
npm.outdated(function (er, d) {
t.equal("1.5.1", d[0][3])
s.close()
Expand All @@ -20,3 +21,8 @@ test("includes devDependencies in outdated", function (t) {
})
})
})

test("cleanup", function (t) {
rimraf.sync(pkg + "/cache")
t.end()
})
8 changes: 7 additions & 1 deletion test/tap/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ var mr = require("npm-registry-mock")
var pkg = __dirname + '/outdated'

test("it should not throw", function (t) {
rimraf.sync(pkg + "/node_modules")
cleanup()
process.chdir(pkg)

mr(common.port, function (s) {
npm.load({
cache: pkg + "/cache",
registry: common.registry }
, function () {
npm.install(".", function (err) {
Expand All @@ -31,3 +32,8 @@ test("cleanup", function (t) {
cleanup()
t.end()
})

function cleanup () {
rimraf.sync(pkg + "/node_modules")
rimraf.sync(pkg + "/cache")
}

0 comments on commit 1e78d55

Please sign in to comment.