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

Method setup

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

Source from the content-addressed store, hash-verified

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

Callers 6

TestRuleComposerUnnestFunction · 0.80
TestCompileFunction · 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