]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/add-remote-git-get-resolved.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / add-remote-git-get-resolved.js
1 'use strict'
2 var test = require('tap').test
3
4 var npm = require('../../lib/npm.js')
5 var common = require('../common-tap.js')
6
7 var normalizeGitUrl = require('normalize-git-url')
8 var getResolved = null
9
10 /**
11  * Note: This is here because `normalizeGitUrl` is usually called
12  * before getResolved is, and receives *that* URL.
13  */
14 function tryGetResolved(uri, treeish) {
15   return getResolved(normalizeGitUrl(uri).url, treeish)
16 }
17
18 test('setup', function (t) {
19   var opts = {
20     registry: common.registry,
21     loglevel: 'silent'
22   }
23   npm.load(opts, function (er) {
24     t.ifError(er, 'npm loaded without error')
25     getResolved = require('../../lib/cache/add-remote-git.js').getResolved
26     t.end()
27   })
28 })
29
30 test('add-remote-git#get-resolved git: passthru', function (t) {
31   verify('git:github.com/foo/repo')
32   verify('git:github.com/foo/repo.git')
33   verify('git://github.com/foo/repo#decadacefadabade')
34   verify('git://github.com/foo/repo.git#decadacefadabade')
35
36   function verify (uri) {
37     t.equal(
38       tryGetResolved(uri, 'decadacefadabade'),
39       'git://github.com/foo/repo.git#decadacefadabade',
40       uri + ' normalized to canonical form git://github.com/foo/repo.git#decadacefadabade'
41     )
42   }
43   t.end()
44 })
45
46 test('add-remote-git#get-resolved SSH', function (t) {
47   t.comment('tests for https://github.com/npm/npm/issues/7961')
48   verify('git@github.com:foo/repo')
49   verify('git@github.com:foo/repo#master')
50   verify('git+ssh://git@github.com/foo/repo#master')
51   verify('git+ssh://git@github.com/foo/repo#decadacefadabade')
52
53   function verify (uri) {
54     t.equal(
55       tryGetResolved(uri, 'decadacefadabade'),
56       'git+ssh://git@github.com/foo/repo.git#decadacefadabade',
57       uri + ' normalized to canonical form git+ssh://git@github.com/foo/repo.git#decadacefadabade'
58     )
59   }
60   t.end()
61 })
62
63 test('add-remote-git#get-resolved HTTPS', function (t) {
64   verify('https://github.com/foo/repo')
65   verify('https://github.com/foo/repo#master')
66   verify('git+https://github.com/foo/repo.git#master')
67   verify('git+https://github.com/foo/repo#decadacefadabade')
68   // DEPRECATED
69   // this is an invalid URL but we normalize it
70   // anyway. Users shouldn't use this in the future. See note
71   // below for how this affected non-hosted URLs.
72   // See https://github.com/npm/npm/issues/8881
73   verify('git+https://github.com:foo/repo.git#master')
74
75   function verify (uri) {
76     t.equal(
77       tryGetResolved(uri, 'decadacefadabade'),
78       'git+https://github.com/foo/repo.git#decadacefadabade',
79       uri + ' normalized to canonical form git+https://github.com/foo/repo.git#decadacefadabade'
80     )
81   }
82   t.end()
83 })
84
85 test('add-remote-git#get-resolved edge cases', function (t) {
86
87   t.equal(
88     tryGetResolved('git+ssh://user@bananaboat.com:galbi/blah.git', 'decadacefadabade'),
89     'git+ssh://user@bananaboat.com:galbi/blah.git#decadacefadabade',
90     'don\'t break non-hosted scp-style locations'
91   )
92
93   t.equal(
94     tryGetResolved('git+ssh://bananaboat:galbi/blah', 'decadacefadabade'),
95     'git+ssh://bananaboat:galbi/blah#decadacefadabade',
96     'don\'t break non-hosted scp-style locations'
97   )
98
99   // DEPRECATED
100   // When we were normalizing all git URIs, git+https: was being
101   // automatically converted to ssh:. Some users were relying
102   // on this funky behavior, so after removing the aggressive
103   // normalization from non-hosted URIs, we brought this back.
104   // See https://github.com/npm/npm/issues/8881
105   t.equal(
106     tryGetResolved('git+https://bananaboat:galbi/blah', 'decadacefadabade'),
107     'git+https://bananaboat/galbi/blah#decadacefadabade',
108     'don\'t break non-hosted scp-style locations'
109   )
110
111   t.equal(
112     tryGetResolved('git+ssh://git.bananaboat.net/foo', 'decadacefadabade'),
113     'git+ssh://git.bananaboat.net/foo#decadacefadabade',
114     'don\'t break non-hosted SSH URLs'
115   )
116
117   t.equal(
118     tryGetResolved('git+ssh://git.bananaboat.net:/foo', 'decadacefadabade'),
119     'git+ssh://git.bananaboat.net:/foo#decadacefadabade',
120     'don\'t break non-hosted SSH URLs'
121   )
122
123   t.equal(
124     tryGetResolved('git://gitbub.com/foo/bar.git', 'decadacefadabade'),
125     'git://gitbub.com/foo/bar.git#decadacefadabade',
126     'don\'t break non-hosted git: URLs'
127   )
128
129   t.end()
130 })