Skip to content

Commit a45ba27

Browse files
author
Milan Meva
committed
add test case for custom hosted git urls
1 parent adbdc01 commit a45ba27

File tree

1 file changed

+49
-0
lines changed
  • workspaces/arborist/test/arborist

1 file changed

+49
-0
lines changed

workspaces/arborist/test/arborist/reify.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,6 +3343,24 @@ t.test('should preserve exact ranges, missing actual tree', async (t) => {
33433343
},
33443344
})
33453345

3346+
const customGitSshPackument = JSON.stringify({
3347+
_id: 'gitssh',
3348+
_rev: 'lkjadflkjasdf',
3349+
name: 'gitssh',
3350+
'dist-tags': { latest: '1.1.1' },
3351+
versions: {
3352+
'1.1.1': {
3353+
name: 'gitssh',
3354+
version: '1.1.1',
3355+
dist: {
3356+
// this is a url that `new URL()` cant parse
3357+
// https://github.com/npm/cli/issues/5278
3358+
tarball: 'git+ssh://git@customgit.com:a/b/c.git#lkjadflkjasdf',
3359+
},
3360+
},
3361+
},
3362+
})
3363+
33463364
const notAUrlPackument = JSON.stringify({
33473365
_id: 'notaurl',
33483366
_rev: 'lkjadflkjasdf',
@@ -3359,6 +3377,37 @@ t.test('should preserve exact ranges, missing actual tree', async (t) => {
33593377
},
33603378
})
33613379

3380+
t.test('valid custom hosted git url', async (t) => {
3381+
const testdir = t.testdir({
3382+
project: {
3383+
'package.json': JSON.stringify({
3384+
name: 'myproject',
3385+
version: '1.0.0',
3386+
dependencies: {
3387+
gitssh: '1.1.1',
3388+
},
3389+
}),
3390+
},
3391+
})
3392+
3393+
tnock(t, 'https://registry.github.com')
3394+
.get('/gitssh')
3395+
.reply(200, customGitSshPackument)
3396+
3397+
const getLogs = warningTracker()
3398+
3399+
const arb = new Arborist({
3400+
path: resolve(testdir, 'project'),
3401+
registry: 'https://registry.github.com',
3402+
cache: resolve(testdir, 'cache'),
3403+
replaceRegistryHost: 'never',
3404+
})
3405+
await arb.reify()
3406+
// since it's not throwing an error on invalid url and returning undefined
3407+
// which trashes the node, so here we can only check if it has no warnings
3408+
t.strictSame(getLogs(), [], 'did not get warnings')
3409+
})
3410+
33623411
t.test('host should not be replaced replaceRegistryHost=never', async (t) => {
33633412
const testdir = t.testdir({
33643413
project: {

0 commit comments

Comments
 (0)