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

Function TestValidateVSAInput

cmd/validate/vsa_test.go:477–556  ·  view source on GitHub ↗

TestValidateVSAInput tests the validateVSAInput function

(t *testing.T)

Source from the content-addressed store, hash-verified

475
476// TestValidateVSAInput tests the validateVSAInput function
477func TestValidateVSAInput(t *testing.T) {
478 tests := []struct {
479 name string
480 data *validateVSAData
481 args []string
482 expectError bool
483 errorMsg string
484 }{
485 {
486 name: "valid with vsa identifier in args",
487 data: &validateVSAData{
488 vsaIdentifier: "",
489 images: "",
490 vsaExpirationStr: "24h",
491 ignoreSignatureVerification: true,
492 },
493 args: []string{"sha256:abc123"},
494 expectError: false,
495 },
496 {
497 name: "valid with vsa flag set",
498 data: &validateVSAData{
499 vsaIdentifier: "sha256:abc123",
500 images: "",
501 vsaExpirationStr: "24h",
502 ignoreSignatureVerification: true,
503 },
504 args: []string{},
505 expectError: false,
506 },
507 {
508 name: "valid with images flag set",
509 data: &validateVSAData{
510 vsaIdentifier: "",
511 images: "snapshot.json",
512 vsaExpirationStr: "24h",
513 ignoreSignatureVerification: true,
514 },
515 args: []string{},
516 expectError: false,
517 },
518 {
519 name: "error when neither vsa nor images provided",
520 data: &validateVSAData{
521 vsaIdentifier: "",
522 images: "",
523 vsaExpirationStr: "24h",
524 ignoreSignatureVerification: true,
525 },
526 args: []string{},
527 expectError: true,
528 errorMsg: "either --vsa, --images, or VSA identifier must be provided",
529 },
530 {
531 name: "error with invalid vsa expiration",
532 data: &validateVSAData{
533 vsaIdentifier: "sha256:abc123",
534 images: "",

Callers

nothing calls this directly

Calls 3

validateVSAInputFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected