Test and debug policies
Prepare test fixtures and inspect policy behavior before a custom policy is reviewed for use.
Before You Begin
Complete environment setup, activate the intended authorization profile, and prepare valid logic. Configure BigQuery access for live-data investigation. Run commands from the repository root; replace YOUR_LOGIC_PATH with your logic file's repository-relative path.
Prepare Test Fixtures
Reference test-data.json from the logic file. Include expected outcomes, snapshot context, and required resource fields. See Structure a custom policy.
Add cases for each intended outcome and incomplete relationships. For the support-attachment example, expect COMPLIANT for a qualifying attachment and UNDETERMINED when no related records establish an outcome. Confirm these expectations against the engine.
Run Policy Tests
Test the selected logic:
repo-manager policies test YOUR_LOGIC_PATH
The argument also accepts a policy, folder, all, or unit-tests. For JUnit output:
repo-manager policies test --format JUNIT YOUR_LOGIC_PATH
JUnit reports default to target/surefire-reports; --output-dir changes the destination. Inspect mismatches and runtime errors before changing expectations. Passing fixtures does not establish live compliance.
Evaluate a Specific Object
Replace RESOURCE_CA_UUID with the resource's Cloudaware UUID:
repo-manager policies evaluate-object YOUR_LOGIC_PATH RESOURCE_CA_UUID
Immediate execution is disabled by default. Inspect the command output and generated script first. --execute runs the returned script using node by default; --command selects another runner. Confirm runner availability before enabling execution.
Generate and Inspect SQL
Generate debugging SQL:
repo-manager policies generate DEBUG YOUR_LOGIC_PATH
Other kinds are FULL, CAPTURE_TEST_DATA, and TESTS. Generation produces a script; execute the intended queries separately in your configured BigQuery tool.
Open the reported output path, typically .generated/debug.sql within the policy directory. Inspect ResultsDetailed and the accompanying diagnostic queries:
| Output | Use |
|---|---|
scope | Distinguish root logic from related lists. |
status, currentStateMessage | Understand the outcome. |
conditionIndex, conditionText | Locate the deciding condition. |
runtimeError | Investigate execution problems. |
objectCount | Count resources taking that path. |
Save useful query edits outside .generated; regeneration and documentation cleanup can remove that directory.
Check Expected Outcomes and Missing Data
For unexpected outcomes, compare inputs, relationships, condition order, and snapshot context. Test absent lookups and disappeared records independently; an engine-generated condition may decide the outcome before an explicit condition matches.
Keep a regression fixture for each corrected case. Continue to Deploy and maintain custom policies after review.