MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestCompiledRuleSemantic

Function TestCompiledRuleSemantic

policy/compiler_test.go:826–844  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

824}
825
826func TestCompiledRuleSemantic(t *testing.T) {
827 policySource := `name: aggregate_semantic
828rule:
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
846func TestCompileYAMLPolicy_ConditionAlwaysFalse(t *testing.T) {
847 policySource := `name: condition_always_false

Callers

nothing calls this directly

Calls 5

NewEnvFunction · 0.92
parsePolicySourceFunction · 0.85
CompileRuleFunction · 0.85
ErrMethod · 0.80
SemanticMethod · 0.45

Tested by

no test coverage detected