mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-26 12:14:17 +00:00
implement hold discovery dropdown in settings. implement a data privacy export feature
This commit is contained in:
@@ -395,3 +395,58 @@ func ExampleSetupTestLogger() {
|
||||
|
||||
// cleanup() will restore the original logger when defer runs
|
||||
}
|
||||
|
||||
func TestShortenSource(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
file string
|
||||
line int
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "our code",
|
||||
file: "/app/atcr.io/pkg/appview/jetstream/processor.go",
|
||||
line: 73,
|
||||
expected: "pkg/appview/jetstream/processor.go:73",
|
||||
},
|
||||
{
|
||||
name: "indigo library",
|
||||
file: "/go/pkg/mod/github.com/bluesky-social/indigo@v0.0.0-20251218205144-034a2c019e64/atproto/identity/handle.go",
|
||||
line: 225,
|
||||
expected: "indigo/atproto/identity/handle.go:225",
|
||||
},
|
||||
{
|
||||
name: "distribution with v3 suffix",
|
||||
file: "/go/pkg/mod/github.com/distribution/distribution/v3@v3.0.0-rc.3/registry/storage/driver.go",
|
||||
line: 123,
|
||||
expected: "distribution/registry/storage/driver.go:123",
|
||||
},
|
||||
{
|
||||
name: "chi router",
|
||||
file: "/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.10/mux.go",
|
||||
line: 42,
|
||||
expected: "chi/mux.go:42",
|
||||
},
|
||||
{
|
||||
name: "simple module without version suffix",
|
||||
file: "/go/pkg/mod/github.com/ipfs/go-cid@v0.4.1/cid.go",
|
||||
line: 99,
|
||||
expected: "go-cid/cid.go:99",
|
||||
},
|
||||
{
|
||||
name: "fallback - unknown path",
|
||||
file: "/some/random/path/to/file.go",
|
||||
line: 10,
|
||||
expected: "path/to/file.go:10",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := shortenSource(tt.file, tt.line)
|
||||
if result != tt.expected {
|
||||
t.Errorf("shortenSource(%q, %d) = %q, want %q", tt.file, tt.line, result, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user