TestProcessSnapshotComponent tests the component processing function
(t *testing.T)
| 1169 | |
| 1170 | // TestProcessSnapshotComponent tests the component processing function |
| 1171 | func 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 | }, |
nothing calls this directly
no test coverage detected