(t *testing.T)
| 441 | } |
| 442 | |
| 443 | func 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) |
nothing calls this directly
no test coverage detected