Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ For **`garm-configurator`** (plain `ops`):

- New unit tests use **Scenario** (`scenario.Context` / `State` / `Relation` / `Secret`),
not `Harness` — see `charms/garm-configurator/tests/unit/`.
- **DO** give every Python test an arrange/act/assert docstring — the convention `STYLE.md`
documents for Go (`// Arrange:` comments), spelled as a docstring:
```python
def test_leader_creates_garm_secrets():
"""
arrange: A leader unit with no GARM secrets yet.
act: Run install.
assert: Both labelled secrets are created, so other units can fetch them by label.
"""
```
State the *why* in the assert line where it isn't obvious ("so other units can fetch them
by label"), not just the mechanical result. For a `parametrize`d test, write one docstring
covering the cases — **DON'T** write one per case.
- **DO** fix a missing AAA docstring on any test you move or edit. It's followed unevenly
(`planner-operator` and `garm` yes; `garm-configurator` and `webhook-gateway-operator` not
yet), so imitating the nearest neighbour is not a reliable guide.
Comment thread
cbartz marked this conversation as resolved.
- Integration tests live in the shared `charms/tests/integration/`.

## 12-factor divergences from the canonical charm-engineer guidance
Expand Down
8 changes: 8 additions & 0 deletions charms/garm/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ charm conventions; this file lists only what's specific to `garm`.
rather than blocking). The port is pinned in the `_workload_config` property.
- Tests: unit in `tests/unit/`; integration via `tox -e garm-integration`
(`charms/tests/integration/test_garm.py`).
- **Scenario tests** — `ops-scenario` expands the `go-framework` extension itself, so this charm
is testable from source with no packed charm. Reaching `ActiveStatus` needs a few fixtures a
plain `ops` charm doesn't; the state builder in `tests/unit/test_charm.py` assembles them, each
annotated with the `paas_charm` behaviour that demands it. **DO** start from it rather than
building a `State` from scratch.
- **DON'T** rebuild the mock-`self` pattern (`GarmCharm.restart(MagicMock())`) these tests
replaced: it can't see what the charm pushed or replanned, so it hid real bugs. Stub only
GARM's HTTP surface (the `garm_api` fixture) and assert on the output `State`.
Loading
Loading