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

Function TestExpressionNodeLimitCheck

cel/cel_test.go:4618–4638  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4616}
4617
4618func TestExpressionNodeLimitCheck(t *testing.T) {
4619 env, err := NewEnv(ExpressionNodeLimit(5), Variable("x", IntType))
4620 if err != nil {
4621 t.Fatalf("NewEnv() failed: %v", err)
4622 }
4623 parseEnv, err := NewEnv(ExpressionNodeLimit(-1), Variable("x", IntType))
4624 if err != nil {
4625 t.Fatalf("NewEnv() failed: %v", err)
4626 }
4627 ast, iss := parseEnv.Parse("x + 1 + 2 + 3 + 4 + 5")
4628 if iss.Err() != nil {
4629 t.Fatalf("Parse() failed: %v", iss.Err())
4630 }
4631 _, iss = env.Check(ast)
4632 if iss.Err() == nil {
4633 t.Fatal("Check() succeeded, expected node count limit error")
4634 }
4635 if !strings.Contains(iss.Err().Error(), "expression node count exceeds limit") {
4636 t.Errorf("Check() got error %v, expected node count limit error", iss.Err())
4637 }
4638}
4639
4640func TestOptionalMapAttributesVariablesLiteralsPartialAndTracking(t *testing.T) {
4641 // 1. Literal & Variable Map optional indexing across various native and CEL map types

Callers

nothing calls this directly

Calls 8

ParseMethod · 0.95
CheckMethod · 0.95
ExpressionNodeLimitFunction · 0.85
ErrMethod · 0.80
NewEnvFunction · 0.70
VariableFunction · 0.70
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected