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

Function TestValidateImageWithVSACheck

internal/image/validate_test.go:443–503  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

441}
442
443func TestValidateImageWithVSACheck(t *testing.T) {
444 tests := []struct {
445 name string
446 vsaExpiration time.Duration
447 vsaChecker *vsa.VSAChecker
448 expectVSACheck bool
449 expectSkip bool
450 }{
451 {
452 name: "VSA checking disabled - zero expiration",
453 vsaExpiration: 0,
454 vsaChecker: createMockVSAChecker(),
455 expectVSACheck: false,
456 expectSkip: false,
457 },
458 {
459 name: "VSA checking disabled - no checker",
460 vsaExpiration: 24 * time.Hour,
461 vsaChecker: createMockVSAChecker(),
462 expectVSACheck: false,
463 expectSkip: false,
464 },
465 {
466 name: "VSA checking enabled with checker",
467 vsaExpiration: 24 * time.Hour,
468 vsaChecker: createMockVSAChecker(),
469 expectVSACheck: true,
470 expectSkip: false, // Placeholder implementation returns "not found"
471 },
472 }
473
474 for _, tt := range tests {
475 t.Run(tt.name, func(t *testing.T) {
476 fs := afero.NewMemMapFs()
477 ctx := utils.WithFS(context.Background(), fs)
478
479 // Create a proper policy interface
480 p, err := policy.NewOfflinePolicy(ctx, policy.Now)
481 require.NoError(t, err)
482
483 // Create a test component
484 comp := app.SnapshotComponent{
485 ContainerImage: "registry.example.com/test:latest",
486 }
487
488 // Create a mock snapshot spec
489 snap := &app.SnapshotSpec{}
490
491 // Create empty evaluators slice
492 evaluators := []evaluator.Evaluator{}
493
494 // Call the function - it should work with basic setup
495 // The function handles VSA checking gracefully when image reference is a tag
496 _, err = ValidateImageWithVSACheck(ctx, comp, snap, p, evaluators, false, tt.vsaChecker, tt.vsaExpiration)
497
498 // The function should succeed even with minimal setup
499 // VSA checking will be skipped due to tag reference (not digest-based)
500 assert.NoError(t, err)

Callers

nothing calls this directly

Calls 5

WithFSFunction · 0.92
NewOfflinePolicyFunction · 0.92
createMockVSACheckerFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected