forked from mirrors/pkg-proxy
* Fix all golangci-lint issues across the codebase Resolve 77 lint issues reported by golangci-lint with gocritic, gocognit, gocyclo, maintidx, dupl, mnd, unparam, ireturn, goconst, and errcheck enabled. Net reduction of ~175 lines through shared helpers and deduplication. * Suppress staticcheck SA1019 for intentional deprecated field usage The Storage.Path field is deprecated but still read for backwards compatibility with existing configs that haven't migrated to the URL field.
23 lines
860 B
Go
23 lines
860 B
Go
package handler
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestRPMHandler_parseRPMPath(t *testing.T) {
|
|
h := &RPMHandler{}
|
|
|
|
assertPathParser(t, "parseRPMPath", h.parseRPMPath, []pathParseCase{
|
|
{"releases/39/Everything/x86_64/os/Packages/n/nginx-1.24.0-1.fc39.x86_64.rpm", "nginx", "1.24.0-1.fc39", "x86_64"},
|
|
{"Packages/kernel-core-6.5.5-200.fc38.x86_64.rpm", "kernel-core", "6.5.5-200.fc38", "x86_64"},
|
|
{"updates/39/Everything/aarch64/Packages/g/git-2.42.0-1.fc39.aarch64.rpm", "git", "2.42.0-1.fc39", "aarch64"},
|
|
{"vim-enhanced-9.0.1000-1.fc38.noarch.rpm", "vim-enhanced", "9.0.1000-1.fc38", "noarch"},
|
|
{"invalid.rpm", "", "", ""},
|
|
{"not-an-rpm-file", "", "", ""},
|
|
})
|
|
}
|
|
|
|
func TestRPMHandler_Routes(t *testing.T) {
|
|
h := NewRPMHandler(nil, "http://localhost:8080")
|
|
assertRoutesBasics(t, h.Routes(), "/repodata/repomd.xml", "/releases/../../../etc/passwd")
|
|
}
|