rocky-data / rocky-data/rocky

policy.rs: three more text renderers print through println!, so no test can read them

Open
#1,908 0 comments 0 reactions 0 assignees View on GitHub
engine good first issue
Dominant language
Rust
Stars
298
Forks
18
Avg merge
8h 7m
Merged PRs (30d)
327

Description

## What

`policy.rs` has three more text renderers that still call `println!`, so no test can read what they produce:

| Function | Command |
|---|---|
| `render_test_text` | `rocky policy test` |
| `render_text` | `rocky policy check` |
| `render_freeze_text` | `rocky policy freeze` / `unfreeze` |

Give each the shape #1879 gave `render_show_text`:

```rust
fn render_test_text(w: &mut W, out: &PolicyTestOutput) -> io::Result<()>
```

## Why this is a separate issue and not part of #1879

Changing the signature is the cheap half and it delivers nothing on its own. The value is the tests, and the assertion has to be the **whole block** — a substring assertion is the exact weakness #1879 exists to close, because round one of the #1874 review lost a line that was present and merely shorter.

So this is four renderers' worth of full-block tests, each needing its own output fixture. That is its own review, not a rider on a PR that closed one renderer.

## Why it matters here

`render_freeze_text` is the highest-value of the three. It prints the `! {note}` lines that warn a freeze is **inert** — recorded but not enforced, because the config has no `[policy]` block. Deleting that loop would pass every test in the repository today, and the operator would be told their freeze took effect when nothing enforces it.

`render_text` (`policy check`) prints the resolved effect and the winning rule, which is the answer an operator acts on.

## Shape

Follow #1879 exactly: sink parameter, `io::Result`, a `Vec` helper in the test module, and a fixture per branch. Mutation-check each test by deleting the line it claims to pin.

Refs #1879, #1874.

Contributor guide

Open the contributing guide

Research direction

Start in policy.rs and follow the shape established by #1879 for render_test_text, render_text, and render_freeze_text. Add a Vec helper in the test module, create a fixture for each branch, and assert each complete output block; mutation-check by deleting the line each test claims to pin.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, testing
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.