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

Function parsePolicy

policy/compiler_test.go:484–499  ·  view source on GitHub ↗
(t testing.TB, name string, parseOpts []ParserOption)

Source from the content-addressed store, hash-verified

482}
483
484func parsePolicy(t testing.TB, name string, parseOpts []ParserOption) *Policy {
485 t.Helper()
486 srcFile := readPolicy(t, fmt.Sprintf("testdata/%s/policy.yaml", name))
487 parser, err := NewParser(parseOpts...)
488 if err != nil {
489 t.Fatalf("NewParser() failed: %v", err)
490 }
491 policy, iss := parser.Parse(srcFile)
492 if iss.Err() != nil {
493 t.Fatalf("Parse() failed: %v", iss.Err())
494 }
495 if policy.name.Value != name {
496 t.Errorf("policy name is %v, wanted %q", policy.name, name)
497 }
498 return policy
499}
500
501func compile(t testing.TB, name string, policy *Policy, envOpts []cel.EnvOption, compilerOpts []CompilerOption) (*cel.Env, *cel.Ast, *cel.Issues) {
502 config := readPolicyConfig(t, fmt.Sprintf("testdata/%s/config.yaml", name))

Callers 7

TestRuleComposerUnnestFunction · 0.85
TestCompileErrorFunction · 0.85
TestWhitespaceHanldingFunction · 0.85
compileMethod · 0.85
compileRuleMethod · 0.85

Calls 4

ParseMethod · 0.95
readPolicyFunction · 0.85
ErrMethod · 0.80
NewParserFunction · 0.70

Tested by

no test coverage detected