TestTriggerTestsWithRunnerOptions tests the TriggerTestsFromCompiler function for a custom policy by providing test runner and compiler options without setting the flag variables.
(t *testing.T)
| 107 | // TestTriggerTestsWithRunnerOptions tests the TriggerTestsFromCompiler function for a custom policy |
| 108 | // by providing test runner and compiler options without setting the flag variables. |
| 109 | func 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 | |
| 124 | func customPolicyParserOption() policy.ParserOption { |
| 125 | return func(p *policy.Parser) (*policy.Parser, error) { |
nothing calls this directly
no test coverage detected