MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestCanonicalName

Function TestCanonicalName

internal/devpkg/package_test.go:189–213  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

187}
188
189func 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}

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
CanonicalNameMethod · 0.65

Tested by

no test coverage detected