(t testing.TB, name string, parseOpts []ParserOption)
| 490 | } |
| 491 | |
| 492 | func parsePolicy(t testing.TB, name string, parseOpts []ParserOption) *Policy { |
| 493 | t.Helper() |
| 494 | srcFile := readPolicy(t, fmt.Sprintf("testdata/%s/policy.yaml", name)) |
| 495 | parser, err := NewParser(parseOpts...) |
| 496 | if err != nil { |
| 497 | t.Fatalf("NewParser() failed: %v", err) |
| 498 | } |
| 499 | policy, iss := parser.Parse(srcFile) |
| 500 | if iss.Err() != nil { |
| 501 | t.Fatalf("Parse() failed: %v", iss.Err()) |
| 502 | } |
| 503 | if policy.name.Value != name { |
| 504 | t.Errorf("policy name is %v, wanted %q", policy.name, name) |
| 505 | } |
| 506 | return policy |
| 507 | } |
| 508 | |
| 509 | func compile(t testing.TB, name string, policy *Policy, envOpts []cel.EnvOption, compilerOpts []CompilerOption) (*cel.Env, *cel.Ast, *cel.Issues) { |
| 510 | config := readPolicyConfig(t, fmt.Sprintf("testdata/%s/config.yaml", name)) |
no test coverage detected