- icons/gen writes to the current directory so `go generate ./internal/master/web/icons` works (output verified byte-identical) - share the registry-host check as imageref.IsRegistryHost (with test) - agents fragment refreshes the "N machines" header count out of band - ignore the saved machine filter at <=760px where the machine list is hidden - aria-current on the active machine filter link, aria-pressed on theme toggle - CLAUDE.md: icons package, SSE ping event, swarm_cluster_id Claude-Session: https://claude.ai/code/session_01GAZsp3P7Qto6JnhipxWUJQ
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package imageref
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParse(t *testing.T) {
|
|
cases := []struct {
|
|
in string
|
|
want Ref
|
|
}{
|
|
{"postgres", Ref{Repo: "postgres"}},
|
|
{"postgres:17.10", Ref{Repo: "postgres", Tag: "17.10"}},
|
|
{"gitea/gitea:1.27.3@sha256:87a6", Ref{Repo: "gitea/gitea", Tag: "1.27.3", Digest: "sha256:87a6"}},
|
|
{"lscr.io/linuxserver/jellyfin@sha256:0f42", Ref{Repo: "lscr.io/linuxserver/jellyfin", Digest: "sha256:0f42"}},
|
|
{"localhost:5000/foo", Ref{Repo: "localhost:5000/foo"}},
|
|
{"localhost:5000/foo:v1", Ref{Repo: "localhost:5000/foo", Tag: "v1"}},
|
|
{"localhost:5000/foo:v1@sha256:ab", Ref{Repo: "localhost:5000/foo", Tag: "v1", Digest: "sha256:ab"}},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.in, func(t *testing.T) {
|
|
got := Parse(c.in)
|
|
assert.Equal(t, c.want, got)
|
|
assert.Equal(t, c.in, got.String(), "String must round-trip")
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestIsRegistryHost(t *testing.T) {
|
|
cases := []struct {
|
|
in string
|
|
want bool
|
|
}{
|
|
{"lscr.io", true},
|
|
{"localhost:5000", true},
|
|
{"localhost", true},
|
|
{"registry:5000", true},
|
|
{"gitea", false},
|
|
{"library", false},
|
|
{"", false},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.in, func(t *testing.T) {
|
|
assert.Equal(t, c.want, IsRegistryHost(c.in))
|
|
})
|
|
}
|
|
}
|