()
| 1079 | } |
| 1080 | |
| 1081 | func (s *testSuite) TestNewResultFormat() { |
| 1082 | cases := []struct { |
| 1083 | name string |
| 1084 | policy string |
| 1085 | material string |
| 1086 | expectErr bool |
| 1087 | expectViolations int |
| 1088 | expectSkipped bool |
| 1089 | expectIgnore bool |
| 1090 | expectReasons []string |
| 1091 | }{ |
| 1092 | { |
| 1093 | name: "result.violations", |
| 1094 | policy: "file://testdata/policy_result_format.yaml", |
| 1095 | material: "{\"specVersion\": \"1.4\"}", |
| 1096 | expectViolations: 1, |
| 1097 | expectIgnore: false, |
| 1098 | }, |
| 1099 | { |
| 1100 | name: "skip", |
| 1101 | policy: "file://testdata/policy_result_format.yaml", |
| 1102 | material: "{\"invalid\": \"1.4\"}", |
| 1103 | expectSkipped: true, |
| 1104 | expectReasons: []string{"invalid input"}, |
| 1105 | expectIgnore: false, |
| 1106 | }, |
| 1107 | { |
| 1108 | name: "skip multiple", |
| 1109 | policy: "file://testdata/policy_result_skipped.yaml", |
| 1110 | material: "{}", |
| 1111 | expectSkipped: true, |
| 1112 | expectReasons: []string{"this one is skipped", "this is also skipped"}, |
| 1113 | expectIgnore: false, |
| 1114 | }, |
| 1115 | { |
| 1116 | name: "ignore", |
| 1117 | policy: "file://testdata/policy_with_ignore.yaml", |
| 1118 | material: "{\"specVersion\": \"1.0\"}", |
| 1119 | expectIgnore: true, |
| 1120 | }, |
| 1121 | } |
| 1122 | |
| 1123 | for _, tc := range cases { |
| 1124 | s.Run(tc.name, func() { |
| 1125 | schema := &v12.CraftingSchema{ |
| 1126 | Materials: []*v12.CraftingSchema_Material{ |
| 1127 | { |
| 1128 | Name: "sbom", |
| 1129 | Type: v12.CraftingSchema_Material_SBOM_CYCLONEDX_JSON, |
| 1130 | }, |
| 1131 | }, |
| 1132 | Policies: &v12.Policies{ |
| 1133 | Materials: []*v12.PolicyAttachment{ |
| 1134 | { |
| 1135 | Policy: &v12.PolicyAttachment_Ref{Ref: tc.policy}, |
| 1136 | }, |
| 1137 | }, |
| 1138 | Attestation: nil, |
nothing calls this directly
no test coverage detected