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

Function TestCompiledRuleSemantic

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

Source from the content-addressed store, hash-verified

813}
814
815func TestCompiledRuleSemantic(t *testing.T) {
816 policySource := `name: aggregate_semantic
817rule:
818 aggregate:
819 - condition: 'true'
820 output: "'foo'"`
821 policy := parsePolicySource(t, "aggregate_semantic", policySource)
822 env, err := cel.NewEnv()
823 if err != nil {
824 t.Fatalf("cel.NewEnv() failed: %v", err)
825 }
826 compiledRule, iss := CompileRule(env, policy)
827 if iss.Err() != nil {
828 t.Fatalf("CompileRule() failed: %v", iss.Err())
829 }
830 if compiledRule.Semantic() != aggregate {
831 t.Errorf("got %v, wanted aggregate", compiledRule.Semantic())
832 }
833}
834
835func TestCompileYAMLPolicy_ConditionAlwaysFalse(t *testing.T) {
836 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