Generalise Proxy Mode Registry Config (#149)

* refactor: generalise registry config

* add test cases & add defensive check for domain match

* fix linter
This commit is contained in:
Sahil Bansal
2026-02-03 07:47:07 +00:00
committed by GitHub
parent 28c7b6c843
commit f90fa0e6a5
6 changed files with 397 additions and 100 deletions
+14 -8
View File
@@ -274,10 +274,16 @@ func TestParseNpmRegistryURL(t *testing.T) {
}
assert.NoError(t, err)
assert.Equal(t, tt.wantName, got.Name)
assert.Equal(t, tt.wantVersion, got.Version)
assert.Equal(t, tt.wantIsTarball, got.IsTarball)
assert.Equal(t, tt.wantIsScoped, got.IsScoped)
assert.Equal(t, tt.wantName, got.GetName())
assert.Equal(t, tt.wantVersion, got.GetVersion())
assert.Equal(t, tt.wantIsTarball, got.IsFileDownload())
// Check scoped status via type assertion - must succeed for npm packages
npmInfo, ok := got.(*npmPackageInfo)
assert.True(t, ok, "expected *npmPackageInfo type")
if ok {
assert.Equal(t, tt.wantIsScoped, npmInfo.IsScoped())
}
})
}
}
@@ -305,7 +311,7 @@ func TestGithubParser_ParseURL(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
parser := githubParser{}
parser := npmGithubParser{}
got, err := parser.ParseURL(tt.urlPath)
if tt.wantErr {
@@ -314,7 +320,7 @@ func TestGithubParser_ParseURL(t *testing.T) {
}
assert.NoError(t, err)
assert.Equal(t, tt.wantIsTarball, got.IsTarball)
assert.Equal(t, tt.wantIsTarball, got.IsFileDownload())
})
}
}
@@ -336,7 +342,7 @@ func TestGithubBlobParser_ParseURL(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
parser := githubBlobParser{}
parser := npmGithubBlobParser{}
got, err := parser.ParseURL(tt.urlPath)
if tt.wantErr {
@@ -345,7 +351,7 @@ func TestGithubBlobParser_ParseURL(t *testing.T) {
}
assert.NoError(t, err)
assert.Equal(t, tt.wantIsTarball, got.IsTarball)
assert.Equal(t, tt.wantIsTarball, got.IsFileDownload())
})
}
}