Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
npm-registry-mock@1.0.0
Browse files Browse the repository at this point in the history
 * npm-registry-mock now sets `connection: close` for registry requests
   to complement change to `npm-registry-client` that sets `connection:
   keep-alive` by default
 * functions that talk to hock are now 'plugins' instead of overloading
   mocks
 * mock responses are no longer deserialized on receiving side
 * callback passed to mock-registry now follows error-first convention

closes npm/npm-registry-mock#25
  • Loading branch information
robertkowalski authored and othiym23 committed Feb 6, 2015
1 parent bca3085 commit 0e8d473
Show file tree
Hide file tree
Showing 50 changed files with 95 additions and 81 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
"marked-man": "~0.1.4",
"nock": "~0.59.0",
"npm-registry-couchapp": "~2.6.2",
"npm-registry-mock": "~0.6.3",
"npm-registry-mock": "~1.0.0",
"require-inject": "~1.1.0",
"tap": "~0.5.0"
},
Expand Down
4 changes: 2 additions & 2 deletions test/disabled/outdated-depth-integer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('outdated depth integer', function (t) {

process.chdir(pkg)

mr(common.port, function (s) {
mr({port : common.port}, function (s) {
npm.load({
cache: pkg + '/cache'
, loglevel: 'silent'
Expand All @@ -49,4 +49,4 @@ test('outdated depth integer', function (t) {
test("cleanup", function (t) {
cleanup()
t.end()
})
})
9 changes: 7 additions & 2 deletions test/tap/404-parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ function setup() {
process.chdir(pkg)
}

function performInstall(cb) {
mr(common.port, function (s) { // create mock registry.
function plugin (server) {
server.get("/test-npm-404-parent-test")
.reply(404, {"error": "version not found"})
}

function performInstall (cb) {
mr({port : common.port, plugin : plugin}, function (er, s) { // create mock registry.
npm.load({registry: common.registry}, function () {
npm.commands.install(pkg, [], function (err) {
cb(err)
Expand Down
2 changes: 1 addition & 1 deletion test/tap/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test("setup", function (t) {
mkdirp(pkg, function (er) {
t.ifError(er, pkg + " made successfully")

mr({port : common.port, mocks : mocks}, function (s) {
mr({port : common.port, plugin : mocks}, function (err, s) {
server = s

fs.writeFile(
Expand Down
6 changes: 3 additions & 3 deletions test/tap/adduser-always-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function mocks(server) {
}

test("npm login", function (t) {
mr({port : common.port, mocks : mocks}, function (s) {
mr({port : common.port, plugin : mocks}, function (er, s) {
var runner = common.npm(
[
"login",
Expand Down Expand Up @@ -61,7 +61,7 @@ test("npm login", function (t) {
})

test("npm login --always-auth", function (t) {
mr({port : common.port, mocks : mocks}, function (s) {
mr({port : common.port, plugin : mocks}, function (er, s) {
var runner = common.npm(
[
"login",
Expand Down Expand Up @@ -98,7 +98,7 @@ test("npm login --always-auth", function (t) {
})

test("npm login --no-always-auth", function (t) {
mr({port : common.port, mocks : mocks}, function (s) {
mr({port : common.port, plugin : mocks}, function (er, s) {
var runner = common.npm(
[
"login",
Expand Down
2 changes: 1 addition & 1 deletion test/tap/adduser-legacy-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test("setup", function (t) {
})

test("npm login", function (t) {
mr({port : common.port, mocks : mocks}, function (s) {
mr({port : common.port, plugin : mocks}, function (er, s) {
var runner = common.npm(
[
"login",
Expand Down
12 changes: 6 additions & 6 deletions test/tap/bugs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test("setup", function (t) {
})

test("npm bugs underscore", function (t) {
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "underscore",
"--registry=" + common.registry,
Expand All @@ -45,7 +45,7 @@ test("npm bugs underscore", function (t) {
})

test("npm bugs optimist - github (https://)", function (t) {
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "optimist",
"--registry=" + common.registry,
Expand All @@ -65,7 +65,7 @@ test("npm bugs optimist - github (https://)", function (t) {
})

test("npm bugs npm-test-peer-deps - no repo", function (t) {
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "npm-test-peer-deps",
"--registry=" + common.registry,
Expand All @@ -85,7 +85,7 @@ test("npm bugs npm-test-peer-deps - no repo", function (t) {
})

test("npm bugs test-repo-url-http - non-github (http://)", function (t) {
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "test-repo-url-http",
"--registry=" + common.registry,
Expand All @@ -105,7 +105,7 @@ test("npm bugs test-repo-url-http - non-github (http://)", function (t) {
})

test("npm bugs test-repo-url-https - non-github (https://)", function (t) {
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "test-repo-url-https",
"--registry=" + common.registry,
Expand All @@ -125,7 +125,7 @@ test("npm bugs test-repo-url-https - non-github (https://)", function (t) {
})

test("npm bugs test-repo-url-ssh - non-github (ssh://)", function (t) {
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm([
"bugs", "test-repo-url-ssh",
"--registry=" + common.registry,
Expand Down
2 changes: 1 addition & 1 deletion test/tap/cache-shasum-fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test("mock reg", function (t) {
mkdirp.sync(cache)
rimraf.sync(cwd)
mkdirp.sync(path.join(cwd, "node_modules"))
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
server = s
t.pass("ok")
t.end()
Expand Down
2 changes: 1 addition & 1 deletion test/tap/cache-shasum.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var server
test("mock reg", function (t) {
rimraf.sync(cache)
mkdirp.sync(cache)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
server = s
t.pass("ok")
t.end()
Expand Down
2 changes: 1 addition & 1 deletion test/tap/circular-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function setup (cb) {
process.chdir(path.resolve(pkg, "minimist"))

fs.mkdirSync(path.resolve(pkg, "minimist/node_modules"))
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
server = s
npm.load({
loglevel: "silent",
Expand Down
2 changes: 1 addition & 1 deletion test/tap/dedupe.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test("dedupe finds the common module and moves it up one level", function (t) {

function setup (cb) {
process.chdir(path.join(__dirname, "dedupe"))
mr(common.port, function (s) { // create mock registry.
mr({port : common.port}, function (er, s) { // create mock registry.
rimraf.sync(path.join(__dirname, "dedupe", "node_modules"))
fs.mkdirSync(path.join(__dirname, "dedupe", "node_modules"))
cb(s)
Expand Down
2 changes: 1 addition & 1 deletion test/tap/dist-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test("setup", function (t) {
mkdirp(pkg, function (er) {
t.ifError(er, pkg + " made successfully")

mr({port : common.port, mocks : mocks}, function (s) {
mr({port : common.port, plugin : mocks}, function (er, s) {
server = s

fs.writeFile(
Expand Down
2 changes: 1 addition & 1 deletion test/tap/false_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test("setup", function(t) {

test("not every pkg.name can be required", function (t) {
t.plan(3)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm([
"install", ".",
"--cache", cache,
Expand Down
2 changes: 1 addition & 1 deletion test/tap/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function getCachePath (uri) {
test("setup", function (t) {
mkdirp.sync(CACHE_DIR)

mr({port: common.port, mocks: mocks}, function (s) {
mr({port: common.port, mocks: mocks}, function (err, s) {
npm.load({cache: CACHE_DIR, registry: common.registry}, function (err) {
t.ifError(err)
server = s
Expand Down
4 changes: 2 additions & 2 deletions test/tap/ignore-shrinkwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var customMocks = {
}

test("ignore-shrinkwrap: using the option", function (t) {
mr({port: common.port, mocks: customMocks}, function (s) {
mr({port: common.port, mocks: customMocks}, function (err, s) {
s._server.on("request", function (req) {
switch (req.url) {
case "/shrinkwrap.js":
Expand All @@ -35,7 +35,7 @@ test("ignore-shrinkwrap: using the option", function (t) {
})

test("ignore-shrinkwrap: NOT using the option", function (t) {
mr({port: common.port, mocks: customMocks}, function (s) {
mr({port: common.port, mocks: customMocks}, function (err, s) {
s._server.on("request", function (req) {
switch (req.url) {
case "/shrinkwrap.js":
Expand Down
4 changes: 2 additions & 2 deletions test/tap/install-cli-unicode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var EXEC_OPTS = {

test("does not use unicode with --unicode false", function (t) {
t.plan(5)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm(["install", "--unicode", "false", "read"], EXEC_OPTS, function (err, code, stdout) {
t.ifError(err, "install package read without unicode success")
t.notOk(code, "npm install exited with code 0")
Expand All @@ -28,7 +28,7 @@ test("does not use unicode with --unicode false", function (t) {
})

test("cleanup", function (t) {
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
common.npm(["uninstall", "read"], EXEC_OPTS, function (err, code) {
t.ifError(err, "uninstall read package success")
t.notOk(code, "npm uninstall exited with code 0")
Expand Down
4 changes: 2 additions & 2 deletions test/tap/install-save-exact.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test("setup", function (t) {

test("\"npm install --save --save-exact\" should install local pkg", function (t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache: pkg + "/cache",
loglevel: "silent",
Expand Down Expand Up @@ -46,7 +46,7 @@ test("\"npm install --save --save-exact\" should install local pkg", function (t
test("\"npm install --save-dev --save-exact\" should install local pkg", function (t) {
resetPackageJSON(pkg)

mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache: pkg + "/cache",
loglevel: "silent",
Expand Down
8 changes: 4 additions & 4 deletions test/tap/install-save-prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test("setup", function (t) {

test("npm install --save with default save-prefix should install local pkg versioned to allow minor updates", function (t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache: pkg + "/cache",
loglevel: "silent",
Expand All @@ -43,7 +43,7 @@ test("npm install --save with default save-prefix should install local pkg versi

test("npm install --save-dev with default save-prefix should install local pkg to dev dependencies versioned to allow minor updates", function (t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache: pkg + "/cache",
loglevel: "silent",
Expand All @@ -69,7 +69,7 @@ test("npm install --save-dev with default save-prefix should install local pkg t

test("npm install --save with \"~\" save-prefix should install local pkg versioned to allow patch updates", function (t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache: pkg + "/cache",
loglevel: "silent",
Expand All @@ -96,7 +96,7 @@ test("npm install --save with \"~\" save-prefix should install local pkg version

test("npm install --save-dev with \"~\" save-prefix should install local pkg to dev dependencies versioned to allow patch updates", function (t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache: pkg + "/cache",
loglevel: "silent",
Expand Down
2 changes: 1 addition & 1 deletion test/tap/install-with-dev-dep-duplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var desiredResultsPath = path.resolve(pkg, "desired-ls-results.json")
test("prefers version from dependencies over devDependencies", function (t) {
t.plan(1)

mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
setup(function (err) {
if (err) return t.fail(err)

Expand Down
2 changes: 1 addition & 1 deletion test/tap/ls-depth-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test("setup", function (t) {
cleanup()
mkdirp.sync(pkg + "/cache")
mkdirp.sync(pkg + "/tmp")
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
var cmd = ["install", "--registry=" + common.registry]
common.npm(cmd, opts, function (er, c) {
if (er) throw er
Expand Down
2 changes: 1 addition & 1 deletion test/tap/ls-depth-unmet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test("setup", function (t) {
cleanup()
mkdirp.sync(cache)
mkdirp.sync(tmp)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
var cmd = ["install", "underscore@1.3.1", "mkdirp", "test-package-with-one-dep", "--registry=" + common.registry]
common.npm(cmd, opts, function (er, c) {
if (er) throw er
Expand Down
2 changes: 1 addition & 1 deletion test/tap/ls-l-depth-0.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var EXEC_OPTS = {

test("setup", function (t) {
setup()
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
server = s

t.end()
Expand Down
4 changes: 2 additions & 2 deletions test/tap/noargs-install-config-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test("does not update the package.json with empty arguments", function (t) {
writePackageJson()
t.plan(1)

mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
var child = createChild([npm, "install"])
child.on("close", function () {
var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8"))
Expand All @@ -67,7 +67,7 @@ test("updates the package.json (adds dependencies) with an argument", function (
writePackageJson()
t.plan(1)

mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
var child = createChild([npm, "install", "underscore"])
child.on("close", function () {
var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8"))
Expand Down
2 changes: 1 addition & 1 deletion test/tap/outdated-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function ansiTrim (str) {
// it"s not running in a tty
test("does not use ansi styling", function (t) {
t.plan(4)
mr(common.port, function (s) { // create mock registry.
mr({port : common.port}, function (er, s) { // create mock registry.
common.npm(
[
"outdated",
Expand Down
2 changes: 1 addition & 1 deletion test/tap/outdated-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test("outdated depth zero", function (t) {

process.chdir(pkg)

mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache: cache
, loglevel: "silent"
Expand Down
2 changes: 1 addition & 1 deletion test/tap/outdated-include-devdependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mkdirp.sync(cache)

test("includes devDependencies in outdated", function (t) {
process.chdir(pkg)
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({cache: cache, registry: common.registry}, function () {
npm.outdated(function (er, d) {
t.equal("1.5.1", d[0][3])
Expand Down
2 changes: 1 addition & 1 deletion test/tap/outdated-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test("it should log json data", function (t) {
cleanup()
process.chdir(pkg)

mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache: pkg + "/cache",
loglevel: "silent",
Expand Down
2 changes: 1 addition & 1 deletion test/tap/outdated-long.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test("it should not throw", function (t) {
console.log = function () {
output.push.apply(output, arguments)
}
mr(common.port, function (s) {
mr({port : common.port}, function (er, s) {
npm.load({
cache : "cache",
loglevel : "silent",
Expand Down
Loading

0 comments on commit 0e8d473

Please sign in to comment.