(t *testing.T)
| 824 | } |
| 825 | |
| 826 | func TestCompiledRuleSemantic(t *testing.T) { |
| 827 | policySource := `name: aggregate_semantic |
| 828 | rule: |
| 829 | aggregate: |
| 830 | - condition: 'true' |
| 831 | output: "'foo'"` |
| 832 | policy := parsePolicySource(t, "aggregate_semantic", policySource) |
| 833 | env, err := cel.NewEnv() |
| 834 | if err != nil { |
| 835 | t.Fatalf("cel.NewEnv() failed: %v", err) |
| 836 | } |
| 837 | compiledRule, iss := CompileRule(env, policy) |
| 838 | if iss.Err() != nil { |
| 839 | t.Fatalf("CompileRule() failed: %v", iss.Err()) |
| 840 | } |
| 841 | if compiledRule.Semantic() != aggregate { |
| 842 | t.Errorf("got %v, wanted aggregate", compiledRule.Semantic()) |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | func TestCompileYAMLPolicy_ConditionAlwaysFalse(t *testing.T) { |
| 847 | policySource := `name: condition_always_false |
nothing calls this directly
no test coverage detected