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

Method setup

policy/compiler_test.go:334–353  ·  view source on GitHub ↗
(t testing.TB, env *cel.Env, ast *cel.Ast)

Source from the content-addressed store, hash-verified

332}
333
334func (r *runner) setup(t testing.TB, env *cel.Env, ast *cel.Ast) {
335 t.Helper()
336 pExpr, err := cel.AstToString(ast)
337 if err != nil {
338 t.Fatalf("cel.AstToString() failed: %v", err)
339 }
340 _, err = cel.AstToCheckedExpr(ast)
341 if err != nil {
342 t.Fatalf("cel.AstToCheckedExpr() failed: %v", err)
343 }
344 if r.expr != "" && normalize(pExpr) != normalize(r.expr) {
345 t.Errorf("cel.AstToString() got %s, wanted %s", pExpr, r.expr)
346 }
347 prg, err := env.Program(ast, cel.EvalOptions(cel.OptOptimize))
348 if err != nil {
349 t.Fatalf("env.Program() failed: %v", err)
350 }
351 r.env = env
352 r.prg = prg
353}
354
355func (r *runner) run(t *testing.T) {
356 tests := readTestSuite(t, fmt.Sprintf("testdata/%s/tests.yaml", r.name))

Callers 6

TestCompileFunction · 0.80
TestRuleComposerUnnestFunction · 0.80
BenchmarkCompileFunction · 0.80
TestFrameResolveNameFunction · 0.80
TestFrameParentFunction · 0.80

Calls 5

AstToStringFunction · 0.92
AstToCheckedExprFunction · 0.92
EvalOptionsFunction · 0.92
normalizeFunction · 0.85
ProgramMethod · 0.80

Tested by

no test coverage detected