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

Function TestValidateSnapshotVSAs

cmd/validate/vsa_test.go:1071–1168  ·  view source on GitHub ↗

TestValidateSnapshotVSAs tests the snapshot validation function

(t *testing.T)

Source from the content-addressed store, hash-verified

1069
1070// TestValidateSnapshotVSAs tests the snapshot validation function
1071func TestValidateSnapshotVSAs(t *testing.T) {
1072 tests := []struct {
1073 name string
1074 data *validateVSAData
1075 expectError bool
1076 errorMsg string
1077 }{
1078 {
1079 name: "valid snapshot validation",
1080 data: &validateVSAData{
1081 images: "snapshot.json",
1082 policyConfig: "test-policy.yaml",
1083 vsaExpirationStr: "24h",
1084 vsaExpiration: 24 * time.Hour,
1085 ignoreSignatureVerification: true,
1086 workers: 2,
1087 policySpec: ecapi.EnterpriseContractPolicySpec{
1088 Sources: []ecapi.Source{
1089 {Name: "test", Policy: []string{"test-policy"}},
1090 },
1091 },
1092 },
1093 expectError: false,
1094 },
1095 {
1096 name: "error with missing snapshot file",
1097 data: &validateVSAData{
1098 images: "nonexistent.json",
1099 policyConfig: "test-policy.yaml",
1100 vsaExpirationStr: "24h",
1101 vsaExpiration: 24 * time.Hour,
1102 ignoreSignatureVerification: true,
1103 workers: 2,
1104 policySpec: ecapi.EnterpriseContractPolicySpec{
1105 Sources: []ecapi.Source{
1106 {Name: "test", Policy: []string{"test-policy"}},
1107 },
1108 },
1109 },
1110 expectError: true,
1111 errorMsg: "failed to parse",
1112 },
1113 {
1114 name: "error with invalid workers count",
1115 data: &validateVSAData{
1116 images: "snapshot.json",
1117 policyConfig: "test-policy.yaml",
1118 vsaExpirationStr: "24h",
1119 vsaExpiration: 24 * time.Hour,
1120 ignoreSignatureVerification: true,
1121 workers: 0, // Invalid worker count
1122 policySpec: ecapi.EnterpriseContractPolicySpec{
1123 Sources: []ecapi.Source{
1124 {Name: "test", Policy: []string{"test-policy"}},
1125 },
1126 },
1127 },
1128 expectError: false, // Workers count is not validated in the function

Callers

nothing calls this directly

Calls 3

runValidateVSAFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected