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

Function TestProcessSnapshotComponent

cmd/validate/vsa_test.go:1171–1256  ·  view source on GitHub ↗

TestProcessSnapshotComponent tests the component processing function

(t *testing.T)

Source from the content-addressed store, hash-verified

1169
1170// TestProcessSnapshotComponent tests the component processing function
1171func TestProcessSnapshotComponent(t *testing.T) {
1172 tests := []struct {
1173 name string
1174 component app.SnapshotComponent
1175 data *validateVSAData
1176 expectError bool
1177 errorMsg string
1178 }{
1179 {
1180 name: "valid component processing",
1181 component: app.SnapshotComponent{
1182 Name: "test-component",
1183 ContainerImage: "nginx:latest",
1184 },
1185 data: &validateVSAData{
1186 vsaExpiration: 24 * time.Hour,
1187 ignoreSignatureVerification: true,
1188 policySpec: ecapi.EnterpriseContractPolicySpec{
1189 Sources: []ecapi.Source{
1190 {Name: "test", Policy: []string{"test-policy"}},
1191 },
1192 },
1193 },
1194 expectError: false,
1195 },
1196 {
1197 name: "component with invalid image reference",
1198 component: app.SnapshotComponent{
1199 Name: "test-component",
1200 ContainerImage: "invalid:image:reference:",
1201 },
1202 data: &validateVSAData{
1203 vsaExpiration: 24 * time.Hour,
1204 ignoreSignatureVerification: true,
1205 policySpec: ecapi.EnterpriseContractPolicySpec{
1206 Sources: []ecapi.Source{
1207 {Name: "test", Policy: []string{"test-policy"}},
1208 },
1209 },
1210 },
1211 expectError: true,
1212 errorMsg: "failed to extract digest",
1213 },
1214 {
1215 name: "component with empty image reference",
1216 component: app.SnapshotComponent{
1217 Name: "test-component",
1218 ContainerImage: "",
1219 },
1220 data: &validateVSAData{
1221 vsaExpiration: 24 * time.Hour,
1222 ignoreSignatureVerification: true,
1223 policySpec: ecapi.EnterpriseContractPolicySpec{
1224 Sources: []ecapi.Source{
1225 {Name: "test", Policy: []string{"test-policy"}},
1226 },
1227 },
1228 },

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected