]> 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-save.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-save.js
1 var fs = require("fs")
2 var ini = require("ini")
3 var test = require("tap").test
4 var npmconf = require("../../lib/config/core.js")
5 var common = require("./00-config-setup.js")
6
7 var expectConf = [
8   "globalconfig = " + common.globalconfig,
9   "email = i@izs.me",
10   "env-thing = asdf",
11   "init.author.name = Isaac Z. Schlueter",
12   "init.author.email = i@izs.me",
13   "init.author.url = http://blog.izs.me/",
14   "init.version = 1.2.3",
15   "proprietary-attribs = false",
16   "npm:publishtest = true",
17   "_npmjs.org:couch = https://admin:password@localhost:5984/registry",
18   "npm-www:nocache = 1",
19   "sign-git-tag = false",
20   "message = v%s",
21   "strict-ssl = false",
22   "_auth = dXNlcm5hbWU6cGFzc3dvcmQ=",
23   "",
24   "[_token]",
25   "AuthSession = yabba-dabba-doodle",
26   "version = 1",
27   "expires = 1345001053415",
28   "path = /",
29   "httponly = true",
30   ""
31 ].join("\n")
32
33 var expectFile = [
34   "globalconfig = " + common.globalconfig,
35   "email = i@izs.me",
36   "env-thing = asdf",
37   "init.author.name = Isaac Z. Schlueter",
38   "init.author.email = i@izs.me",
39   "init.author.url = http://blog.izs.me/",
40   "init.version = 1.2.3",
41   "proprietary-attribs = false",
42   "npm:publishtest = true",
43   "_npmjs.org:couch = https://admin:password@localhost:5984/registry",
44   "npm-www:nocache = 1",
45   "sign-git-tag = false",
46   "message = v%s",
47   "strict-ssl = false",
48   "_auth = dXNlcm5hbWU6cGFzc3dvcmQ=",
49   "",
50   "[_token]",
51   "AuthSession = yabba-dabba-doodle",
52   "version = 1",
53   "expires = 1345001053415",
54   "path = /",
55   "httponly = true",
56   ""
57 ].join("\n")
58
59 test("saving configs", function (t) {
60   npmconf.load(function (er, conf) {
61     if (er)
62       throw er
63     conf.set("sign-git-tag", false, "user")
64     conf.del("nodedir")
65     conf.del("tmp")
66     var foundConf = ini.stringify(conf.sources.user.data)
67     t.same(ini.parse(foundConf), ini.parse(expectConf))
68     fs.unlinkSync(common.userconfig)
69     conf.save("user", function (er) {
70       if (er)
71         throw er
72       var uc = fs.readFileSync(conf.get("userconfig"), "utf8")
73       t.same(ini.parse(uc), ini.parse(expectFile))
74       t.end()
75     })
76   })
77 })
78
79 test("setting prefix", function (t) {
80   npmconf.load(function (er, conf) {
81     if (er)
82       throw er
83
84     conf.prefix = "newvalue"
85     t.same(conf.prefix, "newvalue")
86     t.end()
87   })
88 })