summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/legacy-bundled-git.js
blob: 15fbac84eaeb8ec4085459b8f510757a14fea75c (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'use strict'
var test = require('tap').test
var common = require('../common-tap.js')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
var fixturepath = path.resolve(basepath, 'npm-test-bundled-git')
var modulepath = path.resolve(basepath, 'node_modules')
var installedpath = path.resolve(modulepath, 'npm-test-bundled-git')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir

var minimatchExpected = {
  name: 'minimatch',
  description: 'a glob matcher in javascript',
  version: '0.2.1',
  repository: {
    type: 'git',
    url: 'git://github.com/isaacs/minimatch.git'
  },
  main: 'minimatch.js',
  scripts: {
    test: 'tap test'
  },
  engines: {
    node: '*'
  },
  dependencies: {
    'lru-cache': '~1.0.5'
  },
  devDependencies: {
    tap: '~0.1.3'
  },
  licenses: [
    {
      type: 'MIT',
      url: 'http://github.com/isaacs/minimatch/raw/master/LICENSE'
    }
  ]
}

var fixture = new Tacks(
  Dir({
    README: File(
      'just an npm test\n'
    ),
    'package.json': File({
      name: 'npm-test-bundled-git',
      scripts: {
        test: 'node test.js'
      },
      version: '1.2.5',
      dependencies: {
        glob: 'git://github.com/isaacs/node-glob.git#npm-test'
      },
      bundledDependencies: [
        'glob'
      ]
    })
  })
)
test('setup', function (t) {
  setup()
  t.done()
})
test('bundled-git', function (t) {
  common.npm(['install', '--global-style', fixturepath], {cwd: basepath}, installCheckAndTest)
  function installCheckAndTest (err, code, stdout, stderr) {
    if (err) throw err
    t.is(code, 0, 'install went ok')

    var actual = require(path.resolve(installedpath, 'node_modules/glob/node_modules/minimatch/package.json'))
    Object.keys(minimatchExpected).forEach(function (key) {
      t.isDeeply(actual[key], minimatchExpected[key], key + ' set to the right value')
    })

    common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
  }
  function removeCheckAndDone (err, code, stdout, stderr) {
    if (err) throw err
    t.is(code, 0, 'remove went ok')
    t.done()
  }
})
test('cleanup', function (t) {
  cleanup()
  t.done()
})
function setup () {
  cleanup()
  fixture.create(fixturepath)
  mkdirp.sync(modulepath)
}
function cleanup () {
  fixture.remove(fixturepath)
  rimraf.sync(basepath)
}