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

Function TestTriggerTestsWithRunnerOptions

tools/celtest/test_runner_test.go:109–122  ·  view source on GitHub ↗

TestTriggerTestsWithRunnerOptions tests the TriggerTestsFromCompiler function for a custom policy by providing test runner and compiler options without setting the flag variables.

(t *testing.T)

Source from the content-addressed store, hash-verified

107// TestTriggerTestsWithRunnerOptions tests the TriggerTestsFromCompiler function for a custom policy
108// by providing test runner and compiler options without setting the flag variables.
109func TestTriggerTestsWithRunnerOptions(t *testing.T) {
110 t.Run("test trigger tests custom policy", func(t *testing.T) {
111 envOpt := compiler.EnvironmentFile("../../policy/testdata/k8s/config.yaml")
112 testSuite := TestSuite("../../policy/testdata/k8s/tests.yaml")
113 testCELPolicy := TestExpression("../../policy/testdata/k8s/policy.yaml")
114 c, err := compiler.NewCompiler(envOpt, k8sParserOpts())
115 if err != nil {
116 t.Fatalf("compiler.NewCompiler() failed: %v", err)
117 }
118 compilerOpt := CustomTestCompiler(c)
119 opts := []TestRunnerOption{compilerOpt, testSuite, testCELPolicy}
120 TriggerTests(t, opts...)
121 })
122}
123
124func customPolicyParserOption() policy.ParserOption {
125 return func(p *policy.Parser) (*policy.Parser, error) {

Callers

nothing calls this directly

Calls 7

EnvironmentFileFunction · 0.92
NewCompilerFunction · 0.92
TestExpressionFunction · 0.85
CustomTestCompilerFunction · 0.85
TriggerTestsFunction · 0.85
TestSuiteFunction · 0.70
k8sParserOptsFunction · 0.70

Tested by

no test coverage detected