(t *testing.T)
| 370 | } |
| 371 | |
| 372 | func TestFileExpressionCustomPolicyParser(t *testing.T) { |
| 373 | t.Run("test file expression custom policy parser", func(t *testing.T) { |
| 374 | envOpt := EnvironmentFile("../../policy/testdata/k8s/config.yaml") |
| 375 | parserOpt := policy.ParserOption(func(p *policy.Parser) (*policy.Parser, error) { |
| 376 | p.TagVisitor = policy.K8sTestTagHandler() |
| 377 | return p, nil |
| 378 | }) |
| 379 | compilerOpts := []any{envOpt, parserOpt} |
| 380 | compiler, err := NewCompiler(compilerOpts...) |
| 381 | if err != nil { |
| 382 | t.Fatalf("NewCompiler() failed: %v", err) |
| 383 | } |
| 384 | policyFile := &FileExpression{ |
| 385 | Path: "../../policy/testdata/k8s/policy.yaml", |
| 386 | } |
| 387 | k8sAst, _, err := policyFile.CreateAST(compiler) |
| 388 | if err != nil { |
| 389 | t.Fatalf("CreateAST() failed: %v", err) |
| 390 | } |
| 391 | if k8sAst == nil { |
| 392 | t.Fatalf("CreateAST() returned nil ast") |
| 393 | } |
| 394 | }) |
| 395 | } |
| 396 | |
| 397 | func TestRawExpressionCreateAst(t *testing.T) { |
| 398 | t.Run("test raw expression create ast", func(t *testing.T) { |
nothing calls this directly
no test coverage detected