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

Function TestNormalizeTaggedDigestedString

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

Source from the content-addressed store, hash-verified

88}
89
90func TestNormalizeTaggedDigestedString(t *testing.T) {
91 const digestSuffix = "@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
92
93 for _, test := range []struct{ input, expected string }{
94 {"$$garbage", ""},
95 {"fedora", "fedora"},
96 {"fedora:tag", "fedora:tag"},
97 {digestSuffix, ""},
98 {"docker://fedora:latest", ""},
99 {"docker://fedora:latest" + digestSuffix, ""},
100 {"fedora" + digestSuffix, "fedora" + digestSuffix},
101 {"fedora:latest" + digestSuffix, "fedora" + digestSuffix},
102 {"repo/fedora:123456" + digestSuffix, "repo/fedora" + digestSuffix},
103 {"quay.io/repo/fedora:tag" + digestSuffix, "quay.io/repo/fedora" + digestSuffix},
104 {"localhost/fedora:anothertag" + digestSuffix, "localhost/fedora" + digestSuffix},
105 {"localhost:5000/fedora:v1.2.3.4.5" + digestSuffix, "localhost:5000/fedora" + digestSuffix},
106 } {
107 res, err := normalizeTaggedDigestedString(test.input)
108 if test.expected == "" {
109 assert.Error(t, err, "%v", test)
110 } else {
111 assert.NoError(t, err, "%v", test)
112 assert.Equal(t, test.expected, res, "%v", test)
113 }
114 }
115}

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…