MCPcopy Index your code
hub / github.com/docker/docker-agent / TestNormalizeReference

Function TestNormalizeReference

pkg/remote/pull_test.go:464–507  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

462}
463
464func TestNormalizeReference(t *testing.T) {
465 t.Parallel()
466
467 tests := []struct {
468 name string
469 ref string
470 expected string
471 }{
472 {
473 name: "short reference gets normalized",
474 ref: "agentcatalog/review-pr",
475 expected: "agentcatalog/review-pr:latest",
476 },
477 {
478 name: "fully qualified reference gets normalized to same key",
479 ref: "index.docker.io/agentcatalog/review-pr:latest",
480 expected: "agentcatalog/review-pr:latest",
481 },
482 {
483 name: "tagged reference preserves tag",
484 ref: "agentcatalog/review-pr:v1",
485 expected: "agentcatalog/review-pr:v1",
486 },
487 {
488 name: "digest reference preserves digest",
489 ref: "agentcatalog/review-pr@sha256:0000000000000000000000000000000000000000000000000000000000000000",
490 expected: "agentcatalog/review-pr@sha256:0000000000000000000000000000000000000000000000000000000000000000",
491 },
492 {
493 name: "non-docker-hub registry",
494 ref: "ghcr.io/myorg/agent:v2",
495 expected: "myorg/agent:v2",
496 },
497 }
498
499 for _, tt := range tests {
500 t.Run(tt.name, func(t *testing.T) {
501 t.Parallel()
502 result, err := NormalizeReference(tt.ref)
503 require.NoError(t, err)
504 assert.Equal(t, tt.expected, result)
505 })
506 }
507}
508
509func TestNormalizeReference_InvalidReference(t *testing.T) {
510 t.Parallel()

Callers

nothing calls this directly

Calls 2

NormalizeReferenceFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected