alunduil / alunduil/zfs-replicate
Tests pin the argv and error path in snapshot.list
- Lingua principale
- Python
- Stelle
- 24
- Fork
- 6
- Merge medio
- 3h 11m
- PR unite (30g)
- 49
Descrizione
## User story
As a **maintainer of zfs-replicate's test suite**, I want **tests that fail when `snapshot.list` builds the wrong `zfs list` invocation or mishandles a failed run**, so that **the module's 94% line coverage reflects assertions that actually constrain it**.
## Why
The mutation baseline from #485 leaves 50 survivors in `zfs/replicate/snapshot/list.py`, the largest concentration in the tree. Two clusters explain nearly all of them.
`_list` assembles the option list and nothing asserts on the result, so every literal in it can be rewritten and the suite still passes:
```
- options = ["-H", "-t", "snapshot", "-p", "-o", "name,creation", "-r"]
+ options = ["-H", "-t", "snapshot", "-p", "-o", "NAME,CREATION", "-r"]
```
`list` raises `ZFSReplicateError` on a non-zero return, and its three arguments can each be replaced with `None` or dropped without failing a test:
```
- raise ZFSReplicateError(f"error encountered while listing snapshots of '{filesystem.name}': {error!r}", filesystem, error)
+ raise ZFSReplicateError(f"error encountered while listing snapshots of '{filesystem.name}': {error!r}", filesystem)
```
`docs/reference/testing.md` already says command builders assert on `Command.argv` and `Command.render()` directly. `_list` is a command builder without that test.
## Acceptance criteria
- [ ] A test asserts the full argv `_list` produces, for both the recursive and non-recursive case.
- [ ] A test asserts the error `list` raises on a non-zero return, covering the message, the filesystem, and the cleaned stderr.
- [ ] `poetry run mutmut run --max-children 1 'zfs.replicate.snapshot.list.*'` reports no survivor that a test could have killed. Anything left is noted as an equivalent mutant.
## Out of scope
- The other modules in the #485 baseline; each has its own issue.
- Raising the mutation score anywhere a test would only be asserting on a log line.
## Notes
- Reproduce with `poetry install --with mutation` then `poetry run mutmut run --max-children 1`, and read one survivor with `poetry run mutmut show `. Serial matters: the parallel runner mis-attributes verdicts on this suite.
- Follow-up to #485.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.