diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-04-17 01:12:21 -0700 |
---|---|---|
committer | Chris Dickinson <christopher.s.dickinson@gmail.com> | 2015-04-17 13:26:30 -0700 |
commit | 4870213f9e30e21dcbef19282d04cc40e04035cb (patch) | |
tree | fbf8bd696c4bc40b5c5b81a4bff567b30e864f30 /deps/npm/test/tap/bitbucket-shortcut-package.js | |
parent | 49bb7ded2c78ea6b714b5e3640584ee37a1f6668 (diff) | |
download | node-new-4870213f9e30e21dcbef19282d04cc40e04035cb.tar.gz |
deps: upgrade npm to 2.8.3
Diffstat (limited to 'deps/npm/test/tap/bitbucket-shortcut-package.js')
-rw-r--r-- | deps/npm/test/tap/bitbucket-shortcut-package.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/deps/npm/test/tap/bitbucket-shortcut-package.js b/deps/npm/test/tap/bitbucket-shortcut-package.js new file mode 100644 index 0000000000..bc38bd02fe --- /dev/null +++ b/deps/npm/test/tap/bitbucket-shortcut-package.js @@ -0,0 +1,84 @@ +'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 + +var common = require('../common-tap.js') + +var pkg = path.resolve(__dirname, 'bitbucket-shortcut-package') + +var json = { + name: 'bitbucket-shortcut-package', + version: '0.0.0', + dependencies: { + 'private': 'bitbucket:foo/private' + } +} + +test('setup', function (t) { + setup() + t.end() +}) + +test('bitbucket-shortcut', function (t) { + var cloneUrls = [ + ['git@bitbucket.org:foo/private.git', 'Bitbucket shortcuts try SSH first'], + ['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs second'] + ] + + var npm = requireInject.installGlobally('../../lib/npm.js', { + 'child_process': { + 'execFile': function (cmd, args, options, cb) { + process.nextTick(function () { + if (args[0] !== 'clone') return cb(null, '', '') + var cloneUrl = cloneUrls.shift() + if (cloneUrl) { + t.is(args[3], cloneUrl[0], cloneUrl[1]) + } else { + t.fail('too many attempts to clone') + } + cb(new Error()) + }) + } + } + }) + + var opts = { + cache: path.resolve(pkg, 'cache'), + prefix: pkg, + registry: common.registry, + loglevel: 'silent' + } + npm.load(opts, function (er) { + t.ifError(er, 'npm loaded without error') + npm.commands.install([], function (er) { + t.ok(er, 'mocked install failed as expected') + t.end() + }) + }) +}) + +test('cleanup', function (t) { + cleanup() + t.end() +}) + +function setup () { + cleanup() + mkdirp.sync(pkg) + fs.writeFileSync( + path.join(pkg, 'package.json'), + JSON.stringify(json, null, 2) + ) + process.chdir(pkg) +} + +function cleanup () { + process.chdir(osenv.tmpdir()) + rimraf.sync(pkg) +} |