Generate Rego test skeleton
rego_generate_test_skeletonGenerate test stubs for Rego policies by parsing the AST and inferring input fields to create placeholder test cases, with optional table-driven style.
Instructions
Generate a *_test.rego skeleton from a policy. Parses the AST, finds each non-test rule, and emits one stub test per rule. Existing test_* and todo_test_* rules are skipped automatically -- only testable production rules get stubs. The AST is walked to infer which input.* fields the policy accesses; the inferred shape is used as the placeholder with input as {...} in each stub, so the developer only needs to fill in realistic values rather than guess the structure. With tableStyle: true, each stub uses an every tc in cases { ... } loop so you can add multiple input/expected pairs without duplicating assertion code. The inferredInputShape field in the response shows the detected shape for reference.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Rego source to generate tests for. | |
| tableStyle | No | Generate table-driven test stubs instead of single-case stubs. Each rule gets a `cases` array and an `every tc in cases { ... }` assertion loop. Pair with `rego_test varValues: true` to see which case failed. |