]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/config-new-cafile.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / config-new-cafile.js
1 require('./00-config-setup.js')
2
3 var path = require('path')
4 var fs = require('graceful-fs')
5 var test = require('tap').test
6 var mkdirp = require('mkdirp')
7 var rimraf = require('rimraf')
8 var osenv = require('osenv')
9 var npmconf = require('../../lib/config/core.js')
10
11 var dir = path.resolve(__dirname, 'config-new-cafile')
12 var beep = path.resolve(dir, 'beep.pem')
13
14 test('setup', function (t) {
15   bootstrap()
16   t.end()
17 })
18
19 test('can set new cafile when old is gone', function (t) {
20   t.plan(5)
21   npmconf.load(function (error, conf) {
22     npmconf.loaded = false
23     t.ifError(error)
24     conf.set('cafile', beep, 'user')
25     conf.save('user', function (error) {
26       t.ifError(error)
27       t.equal(conf.get('cafile'), beep)
28       rimraf.sync(beep)
29       npmconf.load(function (error, conf) {
30         if (error) {
31           throw error
32         }
33         t.equal(conf.get('cafile'), beep)
34         conf.del('cafile')
35         conf.save('user', function (error) {
36           t.ifError(error)
37         })
38       })
39     })
40   })
41 })
42
43 test('cleanup', function (t) {
44   cleanup()
45   t.end()
46 })
47
48 function bootstrap () {
49   mkdirp.sync(dir)
50   fs.writeFileSync(beep, '')
51 }
52
53 function cleanup () {
54   process.chdir(osenv.tmpdir())
55   rimraf.sync(dir)
56 }