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

Function TestCoverageStats

tools/celtest/test_coverage_reporter_test.go:26–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestCoverageStats(t *testing.T) {
27 testCases := []struct {
28 name string
29 configPath string
30 testSuitePath string
31 celExpr string
32 compilerOpts []any
33 totalASTNodes int64
34 coveredBranchNodesComplete []int64
35 coveredBranchNodesPartial []int64
36 uncoveredNodes []int64
37 }{
38 {
39 name: "restricted destinations policy coverage",
40 configPath: "../../policy/testdata/restricted_destinations/config.yaml",
41 testSuitePath: "../../policy/testdata/restricted_destinations/tests.yaml",
42 celExpr: "../../policy/testdata/restricted_destinations/policy.yaml",
43 compilerOpts: []any{locationCodeEnvOption()},
44 totalASTNodes: 44,
45 coveredBranchNodesComplete: []int64{1, 7, 11, 12, 19, 23, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 42},
46 coveredBranchNodesPartial: []int64{3, 13, 41},
47 uncoveredNodes: []int64{},
48 },
49 {
50 name: "k8s policy coverage",
51 configPath: "../../policy/testdata/k8s/config.yaml",
52 testSuitePath: "../../policy/testdata/k8s/tests.yaml",
53 celExpr: "../../policy/testdata/k8s/policy.yaml",
54 compilerOpts: []any{k8sParserOpts()},
55 totalASTNodes: 38,
56 coveredBranchNodesComplete: []int64{},
57 coveredBranchNodesPartial: []int64{8, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 31},
58 uncoveredNodes: []int64{5, 6, 7, 11, 12, 38},
59 },
60 {
61 name: "policy with custom policy metadata coverage",
62 testSuitePath: "../../tools/celtest/testdata/custom_policy_tests.yaml",
63 celExpr: "../../tools/celtest/testdata/custom_policy.celpolicy",
64 compilerOpts: []any{customPolicyParserOption(), compiler.PolicyMetadataEnvOption(ParsePolicyVariables)},
65 totalASTNodes: 10,
66 coveredBranchNodesComplete: []int64{1, 2, 3, 6},
67 coveredBranchNodesPartial: []int64{},
68 uncoveredNodes: []int64{},
69 },
70 {
71 name: "raw expression file with unknowns test coverage",
72 configPath: "../../tools/celtest/testdata/config.yaml",
73 testSuitePath: "../../tools/celtest/testdata/raw_expr_tests.yaml",
74 celExpr: "../../tools/celtest/testdata/raw_expr.cel",
75 compilerOpts: []any{fnEnvOption()},
76 totalASTNodes: 8,
77 coveredBranchNodesComplete: []int64{1, 6, 8},
78 coveredBranchNodesPartial: []int64{},
79 uncoveredNodes: []int64{},
80 },
81 }
82 for _, tc := range testCases {
83 t.Run(tc.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 15

ProgramsMethod · 0.95
TestsMethod · 0.95
ExecuteTestMethod · 0.95
PolicyMetadataEnvOptionFuncType · 0.92
EnableMacroCallTrackingFunction · 0.92
EnvironmentFileFunction · 0.92
NavigateASTFunction · 0.92
customPolicyParserOptionFunction · 0.85
fnEnvOptionFunction · 0.85
TestCompilerFunction · 0.85
TestExpressionFunction · 0.85
NewTestRunnerFunction · 0.85

Tested by

no test coverage detected