Part of #5262
Phase -1 Leftover part (Marking the end of phase 1)
Problem
The Phase 1 dual-parse infrastructure (DB migration, DetectRegoVersion(), service wiring, evaluator option, feature flag) was implemented but lacked integration tests verifying the full pipeline end-to-end:
- No test verified that
RegoVersion is correctly detected and passed to DB on CreateRuleType / UpdateRuleType
- No test verified that V1 Rego policies evaluate correctly when
WithRegoVersion(ast.RegoV1) is used
- No edge-case tests for version detection (V0 function syntax,
every keyword, comprehension-heavy policies, syntax errors)
Changes
pkg/ruletypes/service_test.go
- Custom
gomock.Matcher (regoVersionMatcher) that inspects the RegoVersion field in CreateRuleTypeParams / UpdateRuleTypeParams
withRegoEval(def) test helper to build rule types with Rego eval definitions
- 5 new test scenarios:
- CreateRuleType with V0 Rego → DB gets
rego_version = "v0"
- CreateRuleType with V1 Rego → DB gets
rego_version = "v1"
- CreateRuleType without Rego eval → DB gets
rego_version = "v0"
- UpdateRuleType with V0 Rego → DB gets
rego_version = "v0"
- UpdateRuleType with V1 Rego → DB gets
rego_version = "v1"
internal/engine/eval/eval_test.go
- 3 table-driven tests verifying
WithRegoVersion option works through NewRuleEvaluator:
- V1 deny-by-default policy evaluates with
ast.RegoV1
- V1 constraints policy evaluates with
ast.RegoV1
- V0 policy works with explicit
ast.RegoV0 option (regression)
- Dedicated test: V1 policy returns success when input matches
internal/engine/eval/rego/version_test.go
- 5 new edge-case detection tests:
- V0 function syntax (
format_message(...) = msg { ... })
- V1 function syntax (
format_message(...) := msg if { ... })
- V0 partial set with comprehensions
- V1
every keyword
- Syntax error falls back to V0
Part of #5262
Phase -1 Leftover part (Marking the end of phase 1)
Problem
The Phase 1 dual-parse infrastructure (DB migration,
DetectRegoVersion(), service wiring, evaluator option, feature flag) was implemented but lacked integration tests verifying the full pipeline end-to-end:RegoVersionis correctly detected and passed to DB onCreateRuleType/UpdateRuleTypeWithRegoVersion(ast.RegoV1)is usedeverykeyword, comprehension-heavy policies, syntax errors)Changes
pkg/ruletypes/service_test.gogomock.Matcher(regoVersionMatcher) that inspects theRegoVersionfield inCreateRuleTypeParams/UpdateRuleTypeParamswithRegoEval(def)test helper to build rule types with Rego eval definitionsrego_version = "v0"rego_version = "v1"rego_version = "v0"rego_version = "v0"rego_version = "v1"internal/engine/eval/eval_test.goWithRegoVersionoption works throughNewRuleEvaluator:ast.RegoV1ast.RegoV1ast.RegoV0option (regression)internal/engine/eval/rego/version_test.goformat_message(...) = msg { ... })format_message(...) := msg if { ... })everykeyword