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

Function parsePolicy

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

Source from the content-addressed store, hash-verified

490}
491
492func parsePolicy(t testing.TB, name string, parseOpts []ParserOption) *Policy {
493 t.Helper()
494 srcFile := readPolicy(t, fmt.Sprintf("testdata/%s/policy.yaml", name))
495 parser, err := NewParser(parseOpts...)
496 if err != nil {
497 t.Fatalf("NewParser() failed: %v", err)
498 }
499 policy, iss := parser.Parse(srcFile)
500 if iss.Err() != nil {
501 t.Fatalf("Parse() failed: %v", iss.Err())
502 }
503 if policy.name.Value != name {
504 t.Errorf("policy name is %v, wanted %q", policy.name, name)
505 }
506 return policy
507}
508
509func compile(t testing.TB, name string, policy *Policy, envOpts []cel.EnvOption, compilerOpts []CompilerOption) (*cel.Env, *cel.Ast, *cel.Issues) {
510 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