TestExtractImageDigest tests the ExtractImageDigest function
(t *testing.T)
| 458 | |
| 459 | // TestExtractImageDigest tests the ExtractImageDigest function |
| 460 | func 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 |
| 497 | func TestValidateVSAAndComparePolicyIfNeeded(t *testing.T) { |
nothing calls this directly
no test coverage detected