MCPcopy Create free account
hub / github.com/containers/common / TestNormalizeName

Function TestNormalizeName

libimage/normalize_test.go:65–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestNormalizeName(t *testing.T) {
66 const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
67
68 for _, c := range []struct{ input, expected string }{
69 {"#", ""}, // Clearly invalid
70 {"example.com/busybox", "example.com/busybox:latest"}, // Qualified name-only
71 {"example.com/busybox:notlatest", "example.com/busybox:notlatest"}, // Qualified name:tag
72 {"example.com/busybox" + digestSuffix, "example.com/busybox" + digestSuffix}, // Qualified name@digest
73 {"example.com/busybox:notlatest" + digestSuffix, "example.com/busybox" + digestSuffix}, // Qualified name:tag@digest
74 {"busybox:latest", "localhost/busybox:latest"}, // Unqualified name-only
75 {"busybox:latest" + digestSuffix, "localhost/busybox" + digestSuffix}, // Unqualified name:tag@digest
76 {"localhost/busybox", "localhost/busybox:latest"}, // Qualified with localhost
77 {"ns/busybox:latest", "localhost/ns/busybox:latest"}, // Unqualified with a dot-less namespace
78 {"docker.io/busybox:latest", "docker.io/library/busybox:latest"}, // docker.io without /library/
79 } {
80 res, err := NormalizeName(c.input)
81 if c.expected == "" {
82 assert.Error(t, err, c.input)
83 } else {
84 require.NoError(t, err, c.input)
85 assert.Equal(t, c.expected, res.String())
86 }
87 }
88}
89
90func TestNormalizeTaggedDigestedString(t *testing.T) {
91 const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"

Callers

nothing calls this directly

Calls 3

NormalizeNameFunction · 0.85
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…