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

Function TestWithTag

docker/reference/reference_test.go:467–527  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

465}
466
467func TestWithTag(t *testing.T) {
468 testcases := []struct {
469 name string
470 digest digest.Digest
471 tag string
472 combined string
473 }{
474 {
475 name: "test.com/foo",
476 tag: "tag",
477 combined: "test.com/foo:tag",
478 },
479 {
480 name: "foo",
481 tag: "tag2",
482 combined: "foo:tag2",
483 },
484 {
485 name: "test.com:8000/foo",
486 tag: "tag4",
487 combined: "test.com:8000/foo:tag4",
488 },
489 {
490 name: "test.com:8000/foo",
491 tag: "TAG5",
492 combined: "test.com:8000/foo:TAG5",
493 },
494 {
495 name: "test.com:8000/foo",
496 digest: "sha256:1234567890098765432112345667890098765",
497 tag: "TAG5",
498 combined: "test.com:8000/foo:TAG5@sha256:1234567890098765432112345667890098765",
499 },
500 }
501 for _, testcase := range testcases {
502 failf := func(format string, v ...interface{}) {
503 t.Logf(strconv.Quote(testcase.name)+": "+format, v...)
504 t.Fail()
505 }
506
507 named, err := WithName(testcase.name)
508 if err != nil {
509 failf("error parsing name: %s", err)
510 }
511 if testcase.digest != "" {
512 canonical, err := WithDigest(named, testcase.digest)
513 if err != nil {
514 failf("error adding digest")
515 }
516 named = canonical
517 }
518
519 tagged, err := WithTag(named, testcase.tag)
520 if err != nil {
521 failf("WithTag failed: %s", err)
522 }
523 if tagged.String() != testcase.combined {
524 failf("unexpected: got %q, expected %q", tagged.String(), testcase.combined)

Callers

nothing calls this directly

Calls 4

WithNameFunction · 0.85
WithDigestFunction · 0.85
WithTagFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…