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
100
101
|
'use strict'
var test = require('tap').test
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
test('setup', function (t) {
var opts = {
registry: common.registry,
loglevel: 'silent'
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
t.end()
})
})
test('add-remote-git#get-resolved git: passthru', function (t) {
var getResolved = require('../../lib/cache/add-remote-git.js').getResolved
verify('git:github.com/foo/repo')
verify('git:github.com/foo/repo.git')
verify('git://github.com/foo/repo#decadacefadabade')
verify('git://github.com/foo/repo.git#decadacefadabade')
function verify (uri) {
t.equal(
getResolved(uri, 'decadacefadabade'),
'git://github.com/foo/repo.git#decadacefadabade',
uri + ' normalized to canonical form git://github.com/foo/repo.git#decadacefadabade'
)
}
t.end()
})
test('add-remote-git#get-resolved SSH', function (t) {
var getResolved = require('../../lib/cache/add-remote-git.js').getResolved
t.comment('tests for https://github.com/npm/npm/issues/7961')
verify('git@github.com:foo/repo')
verify('git@github.com:foo/repo#master')
verify('git+ssh://git@github.com/foo/repo#master')
verify('git+ssh://git@github.com/foo/repo#decadacefadabade')
function verify (uri) {
t.equal(
getResolved(uri, 'decadacefadabade'),
'git+ssh://git@github.com/foo/repo.git#decadacefadabade',
uri + ' normalized to canonical form git+ssh://git@github.com/foo/repo.git#decadacefadabade'
)
}
t.end()
})
test('add-remote-git#get-resolved HTTPS', function (t) {
var getResolved = require('../../lib/cache/add-remote-git.js').getResolved
verify('https://github.com/foo/repo')
verify('https://github.com/foo/repo#master')
verify('git+https://github.com/foo/repo.git#master')
verify('git+https://github.com/foo/repo#decadacefadabade')
function verify (uri) {
t.equal(
getResolved(uri, 'decadacefadabade'),
'git+https://github.com/foo/repo.git#decadacefadabade',
uri + ' normalized to canonical form git+https://github.com/foo/repo.git#decadacefadabade'
)
}
t.end()
})
test('add-remote-git#get-resolved edge cases', function (t) {
var getResolved = require('../../lib/cache/add-remote-git.js').getResolved
t.notOk(
getResolved('git@bananaboat.com:galbi.git', 'decadacefadabade'),
'non-hosted Git SSH non-URI strings are invalid'
)
t.equal(
getResolved('git+ssh://git.bananaboat.net/foo', 'decadacefadabade'),
'git+ssh://git.bananaboat.net/foo#decadacefadabade',
'don\'t break non-hosted SSH URLs'
)
t.equal(
getResolved('git://gitbub.com/foo/bar.git', 'decadacefadabade'),
'git://gitbub.com/foo/bar.git#decadacefadabade',
'don\'t break non-hosted git: URLs'
)
t.comment('test for https://github.com/npm/npm/issues/3224')
t.equal(
getResolved('git+ssh://git@git.example.com:my-repo.git#9abe82cb339a70065e75300f62b742622774693c', 'decadacefadabade'),
'git+ssh://git@git.example.com:my-repo.git#decadacefadabade',
'preserve weird colon in semi-standard ssh:// URLs'
)
t.end()
})
|