summaryrefslogtreecommitdiff
path: root/deps/node/deps/npm/test/tap/outdated-git.js
blob: 2a595e5288934c70e3b7576d7b0dd935a3467cda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var path = require('path')

var test = require('tap').test
var mkdirp = require('mkdirp')
var fs = require('graceful-fs')
var rimraf = require('rimraf')

var common = require('../common-tap.js')
var npm = require('../../')

// config
var pkg = path.resolve(__dirname, 'outdated-git')
var cache = path.resolve(pkg, 'cache')
var json = {
  name: 'outdated-git',
  author: 'Rocko Artischocko',
  description: 'fixture',
  version: '0.0.1',
  main: 'index.js',
  dependencies: {
    'foo-github': 'robertkowalski/foo',
    'foo-private': 'git://github.com/robertkowalski/foo-private.git',
    'foo-private-credentials': 'git://user:pass@github.com/robertkowalski/foo-private.git'
  }
}

test('setup', function (t) {
  setup()
  t.end()
})

test('discovers new versions in outdated', function (t) {
  process.chdir(pkg)
  t.plan(7)
  npm.load({cache: cache, registry: common.registry, loglevel: 'silent'}, function () {
    npm.commands.outdated([], function (er, d) {
      t.ifError(er, 'npm outdated completed successfully')
      t.is(process.exitCode, 1, 'exitCode set to 1')
      process.exitCode = 0
      t.equal(d[0][3], 'git')
      t.equal(d[0][4], 'git')
      t.equal(d[0][5], 'github:robertkowalski/foo')
      t.equal(d[1][5], 'git://github.com/robertkowalski/foo-private.git')
      t.equal(d[2][5], 'git://user:pass@github.com/robertkowalski/foo-private.git')
    })
  })
})

test('cleanup', function (t) {
  cleanup()
  t.end()
})

function setup () {
  mkdirp.sync(cache)
  fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2), 'utf8')
}

function cleanup () {
  rimraf.sync(pkg)
}