Cybersecurity-Projects/PROJECTS/beginner/simple-vulnerability-scanner/internal/pypi/client_test.go

50 lines
944 B
Go

/*
©AngelaMos | 2026
client_test.go
Tests for PEP 503 package name normalization in client.go
Tests:
TestNormalizeName - mixed case, underscores, dots, and consecutive separators all normalize to lowercase hyphenated form
*/
package pypi
import (
"testing"
)
func TestNormalizeName(t *testing.T) {
t.Parallel()
tests := []struct {
input string
want string
}{
{"requests", "requests"},
{"Requests", "requests"},
{"REQUESTS", "requests"},
{"some-package", "some-package"},
{"some_package", "some-package"},
{"some.package", "some-package"},
{"Some_Package", "some-package"},
{"my---package", "my-package"},
{"my__.package", "my-package"},
{"Flask", "flask"},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
t.Parallel()
got := NormalizeName(tt.input)
if got != tt.want {
t.Errorf(
"NormalizeName(%q) = %q, want %q",
tt.input, got, tt.want,
)
}
})
}
}