]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/unpublish-config.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / unpublish-config.js
1 var fs = require('graceful-fs')
2 var http = require('http')
3 var path = require('path')
4
5 var mkdirp = require('mkdirp')
6 var osenv = require('osenv')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
9
10 var pkg = path.join(__dirname, 'npm-test-unpublish-config')
11 var fixturePath = path.join(pkg, 'fixture_npmrc')
12
13 var common = require('../common-tap.js')
14
15 var json = {
16   name: 'npm-test-unpublish-config',
17   version: '1.2.3',
18   publishConfig: { registry: common.registry }
19 }
20
21 test('setup', function (t) {
22   mkdirp.sync(pkg)
23
24   fs.writeFileSync(
25     path.join(pkg, 'package.json'),
26     JSON.stringify(json), 'utf8'
27   )
28   fs.writeFileSync(
29     fixturePath,
30     '//localhost:1337/:_authToken = beeeeeeeeeeeeef\n' +
31       'registry = http://lvh.me:4321/registry/path\n'
32   )
33
34   t.end()
35 })
36
37 test('cursory test of unpublishing with config', function (t) {
38   var child
39   t.plan(4)
40   http.createServer(function (req, res) {
41     t.pass('got request on the fakey fake registry')
42     this.close()
43     res.statusCode = 500
44     res.end(JSON.stringify({
45       error: 'shh no tears, only dreams now'
46     }))
47     child.kill('SIGHUP')
48   }).listen(common.port, function () {
49     t.pass('server is listening')
50
51     child = common.npm(
52       [
53         '--userconfig', fixturePath,
54         '--loglevel', 'silent',
55         '--force',
56         'unpublish'
57       ],
58       {
59         cwd: pkg,
60         stdio: 'inherit',
61         env: {
62           'npm_config_cache_lock_stale': 1000,
63           'npm_config_cache_lock_wait': 1000,
64           HOME: process.env.HOME,
65           Path: process.env.PATH,
66           PATH: process.env.PATH,
67           USERPROFILE: osenv.home()
68         }
69       },
70       function (err, code) {
71         t.ifError(err, 'publish command finished successfully')
72         t.notOk(code, 'npm install exited with code 0')
73       }
74     )
75   })
76 })
77
78 test('cleanup', function (t) {
79   process.chdir(osenv.tmpdir())
80   rimraf.sync(pkg)
81   t.end()
82 })