MCPcopy Create free account
hub / github.com/conforma/cli / TestExtractImageDigest

Function TestExtractImageDigest

internal/validate/vsa/validator_test.go:460–494  ·  view source on GitHub ↗

TestExtractImageDigest tests the ExtractImageDigest function

(t *testing.T)

Source from the content-addressed store, hash-verified

458
459// TestExtractImageDigest tests the ExtractImageDigest function
460func TestExtractImageDigest(t *testing.T) {
461 tests := []struct {
462 name string
463 identifier string
464 expected string
465 }{
466 {
467 name: "sha256 digest",
468 identifier: "sha256:abc123def456789",
469 expected: "sha256:abc123def456789",
470 },
471 {
472 name: "image reference",
473 identifier: "registry.io/repo:tag",
474 expected: "registry.io/repo:tag",
475 },
476 {
477 name: "empty string",
478 identifier: "",
479 expected: "",
480 },
481 {
482 name: "image reference without digest",
483 identifier: "registry.io/repo:latest",
484 expected: "registry.io/repo:latest",
485 },
486 }
487
488 for _, tt := range tests {
489 t.Run(tt.name, func(t *testing.T) {
490 result := ExtractImageDigest(tt.identifier)
491 assert.Equal(t, tt.expected, result)
492 })
493 }
494}
495
496// TestValidateVSAAndComparePolicyIfNeeded tests the ValidateVSAAndComparePolicyIfNeeded function
497func TestValidateVSAAndComparePolicyIfNeeded(t *testing.T) {

Callers

nothing calls this directly

Calls 2

ExtractImageDigestFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected