(t *testing.T)
| 187 | } |
| 188 | |
| 189 | func TestCanonicalName(t *testing.T) { |
| 190 | tests := []struct { |
| 191 | pkgName string |
| 192 | expectedName string |
| 193 | }{ |
| 194 | {"go", "go"}, |
| 195 | {"go@latest", "go"}, |
| 196 | {"go@1.21", "go"}, |
| 197 | {"runx:golangci/golangci-lint@latest", "runx:golangci/golangci-lint"}, |
| 198 | {"runx:golangci/golangci-lint@v0.0.2", "runx:golangci/golangci-lint"}, |
| 199 | {"runx:golangci/golangci-lint", "runx:golangci/golangci-lint"}, |
| 200 | {"github:NixOS/nixpkgs/12345", ""}, |
| 201 | {"path:/to/my/file", ""}, |
| 202 | } |
| 203 | |
| 204 | for _, tt := range tests { |
| 205 | t.Run(tt.pkgName, func(t *testing.T) { |
| 206 | pkg := PackageFromStringWithDefaults(tt.pkgName, &lockfile{}) |
| 207 | got := pkg.CanonicalName() |
| 208 | if got != tt.expectedName { |
| 209 | t.Errorf("Expected canonical name %q, but got %q", tt.expectedName, got) |
| 210 | } |
| 211 | }) |
| 212 | } |
| 213 | } |
nothing calls this directly
no test coverage detected