(t testing.TB, policyYAML, filename string, composerOpts ...ComposerOption)
| 291 | } |
| 292 | |
| 293 | func parseAndComposeRule(t testing.TB, policyYAML, filename string, composerOpts ...ComposerOption) (*cel.Env, *CompiledRule, *cel.Ast) { |
| 294 | t.Helper() |
| 295 | src := StringSource(policyYAML, filename) |
| 296 | parser, err := NewParser() |
| 297 | if err != nil { |
| 298 | t.Fatalf("NewParser() failed: %v", err) |
| 299 | } |
| 300 | policy, iss := parser.Parse(src) |
| 301 | if iss.Err() != nil { |
| 302 | t.Fatalf("parser.Parse() failed: %v", iss.Err()) |
| 303 | } |
| 304 | env, err := cel.NewEnv(cel.OptionalTypes(), ext.Bindings()) |
| 305 | if err != nil { |
| 306 | t.Fatalf("cel.NewEnv() failed: %v", err) |
| 307 | } |
| 308 | compiledRule, iss := CompileRule(env, policy) |
| 309 | if iss.Err() != nil { |
| 310 | t.Fatalf("CompileRule() failed: %v", iss.Err()) |
| 311 | } |
| 312 | composer, err := NewRuleComposer(env, composerOpts...) |
| 313 | if err != nil { |
| 314 | t.Fatalf("NewRuleComposer() failed: %v", err) |
| 315 | } |
| 316 | compAST, iss := composer.Compose(compiledRule) |
| 317 | if iss.Err() != nil { |
| 318 | t.Fatalf("composer.Compose() failed: %v", iss.Err()) |
| 319 | } |
| 320 | return env, compiledRule, compAST |
| 321 | } |
no test coverage detected