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

Function parsePolicy

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

Source from the content-addressed store, hash-verified

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