summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/github-shortcut.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/tap/github-shortcut.js')
-rw-r--r--deps/npm/test/tap/github-shortcut.js49
1 files changed, 26 insertions, 23 deletions
diff --git a/deps/npm/test/tap/github-shortcut.js b/deps/npm/test/tap/github-shortcut.js
index c0a67d21a4..641d64f3b9 100644
--- a/deps/npm/test/tap/github-shortcut.js
+++ b/deps/npm/test/tap/github-shortcut.js
@@ -1,18 +1,21 @@
'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-var mkdirp = require('mkdirp')
-var osenv = require('osenv')
-var requireInject = require('require-inject')
-var rimraf = require('rimraf')
-var test = require('tap').test
+const BB = require('bluebird')
-var common = require('../common-tap.js')
+const fs = require('graceful-fs')
+const path = require('path')
-var pkg = path.resolve(__dirname, 'github-shortcut')
+const mkdirp = require('mkdirp')
+const osenv = require('osenv')
+const requireInject = require('require-inject')
+const rimraf = require('rimraf')
+const test = require('tap').test
-var json = {
+const common = require('../common-tap.js')
+
+const pkg = path.resolve(__dirname, 'github-shortcut')
+
+const json = {
name: 'github-shortcut',
version: '0.0.0'
}
@@ -23,38 +26,38 @@ test('setup', function (t) {
})
test('github-shortcut', function (t) {
- var cloneUrls = [
+ const cloneUrls = [
['git://github.com/foo/private.git', 'GitHub shortcuts try git URLs first'],
['https://github.com/foo/private.git', 'GitHub shortcuts try HTTPS URLs second'],
- ['git@github.com:foo/private.git', 'GitHub shortcuts try SSH third']
+ ['ssh://git@github.com/foo/private.git', 'GitHub shortcuts try SSH third']
]
- var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
+ const npm = requireInject.installGlobally('../../lib/npm.js', {
+ 'pacote/lib/util/git': {
+ 'revs': (repo, opts) => {
+ return BB.resolve().then(() => {
+ const cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
+ t.is(repo, cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
- cb(new Error('execFile mock fails on purpose'))
+ throw new Error('git.revs mock fails on purpose')
})
}
}
})
- var opts = {
+ const opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
- t.plan(1 + cloneUrls.length)
+ t.plan(2 + cloneUrls.length)
npm.load(opts, function (err) {
t.ifError(err, 'npm loaded without error')
- npm.commands.install(['foo/private'], function (er, result) {
+ npm.commands.install(['foo/private'], function (err, result) {
+ t.match(err.message, /mock fails on purpose/, 'mocked install failed as expected')
t.end()
})
})