(t *testing.T)
| 246 | } |
| 247 | |
| 248 | func TestWhitespaceHandlingErrorPresentation(t *testing.T) { |
| 249 | policy := parsePolicy(t, "yaml_parsing_cel_error", []ParserOption{}) |
| 250 | _, _, iss := compile(t, "yaml_parsing_cel_error", policy, []cel.EnvOption{}, []CompilerOption{}) |
| 251 | if iss.Err() == nil { |
| 252 | t.Fatalf("compile('yaml_parsing_cel_error') did not error, wanted error") |
| 253 | } |
| 254 | |
| 255 | wantErrors := []string{ |
| 256 | `ERROR: testdata/yaml_parsing_cel_error/policy.yaml:11:16: found no matching overload for '_+_' applied to '(string, int)' |
| 257 | | ("bar" + 1) |
| 258 | | ...............^`, |
| 259 | `ERROR: testdata/yaml_parsing_cel_error/policy.yaml:15:18: found no matching overload for '_+_' applied to '(string, int)' |
| 260 | | ("bar" + 1) |
| 261 | | .................^`, |
| 262 | `ERROR: testdata/yaml_parsing_cel_error/policy.yaml:19:16: found no matching overload for '_+_' applied to '(string, int)' |
| 263 | | ("bar" + 1) |
| 264 | | ...............^`, |
| 265 | `ERROR: testdata/yaml_parsing_cel_error/policy.yaml:23:18: found no matching overload for '_+_' applied to '(string, int)' |
| 266 | | ("bar" + 1) |
| 267 | | .................^`, |
| 268 | } |
| 269 | found := false |
| 270 | for _, wantError := range wantErrors { |
| 271 | if !strings.Contains(iss.Err().Error(), wantError) { |
| 272 | found = true |
| 273 | t.Errorf("compile('yaml_parsing_cel_error') does not contain error %s", wantError) |
| 274 | } |
| 275 | } |
| 276 | if found { |
| 277 | t.Errorf("compile('yaml_parsing_cel_error') missing errors, got: %s", iss.Err().Error()) |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | func BenchmarkCompile(b *testing.B) { |
| 282 | for _, tst := range policyTests { |
nothing calls this directly
no test coverage detected