MCPcopy Create free account
hub / github.com/containers/image / TestWithNameFailure

Function TestWithNameFailure

docker/reference/reference_test.go:239–280  ·  view source on GitHub ↗

TestWithNameFailure tests cases where WithName should fail. Cases where it should succeed are covered by TestSplitHostname, below.

(t *testing.T)

Source from the content-addressed store, hash-verified

237// TestWithNameFailure tests cases where WithName should fail. Cases where it
238// should succeed are covered by TestSplitHostname, below.
239func TestWithNameFailure(t *testing.T) {
240 testcases := []struct {
241 input string
242 err error
243 }{
244 {
245 input: "",
246 err: ErrNameEmpty,
247 },
248 {
249 input: ":justtag",
250 err: ErrReferenceInvalidFormat,
251 },
252 {
253 input: "@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
254 err: ErrReferenceInvalidFormat,
255 },
256 {
257 input: "validname@invaliddigest:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
258 err: ErrReferenceInvalidFormat,
259 },
260 {
261 input: strings.Repeat("a/", 128) + "a:tag",
262 err: ErrNameTooLong,
263 },
264 {
265 input: "aa/asdf$$^/aa",
266 err: ErrReferenceInvalidFormat,
267 },
268 }
269 for _, testcase := range testcases {
270 failf := func(format string, v ...interface{}) {
271 t.Logf(strconv.Quote(testcase.input)+": "+format, v...)
272 t.Fail()
273 }
274
275 _, err := WithName(testcase.input)
276 if err == nil {
277 failf("no error parsing name. expected: %s", testcase.err)
278 }
279 }
280}
281
282func TestSplitHostname(t *testing.T) {
283 testcases := []struct {

Callers

nothing calls this directly

Calls 1

WithNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…