Background
In PR #326, snapshot regression tests were added for localised CLI long-help output (src/cli/parser_tests.rs). The tests currently embed insta::assert_snapshot! directly inside the test body, which causes irreversible filesystem I/O (reading or writing snapshot files) as an indistinguishable side-effect of what should be a pure query operation.
Problem
insta's assert_snapshot! macro unconditionally performs filesystem mutations during test execution. There is no clear boundary between:
- the query path – rendering, normalising, and asserting on the help text; and
- the command path – persisting or verifying the snapshot on disk.
This violates the CQS principle and makes test intent harder to reason about.
Proposed resolution
Refactor the snapshot tests to separate concerns explicitly:
- Extract a pure helper function that returns the normalised rendered help string for a given locale.
- Assert on the returned string in unit-style tests (no I/O).
- Invoke
assert_snapshot! only from a clearly labelled snapshot-acceptance layer, or use insta's explicit Settings API (Settings::bind, Settings::set_snapshot_path, etc.) in a dedicated snapshot-acceptance test function that is clearly named and documented as having filesystem side-effects.
References
Background
In PR #326, snapshot regression tests were added for localised CLI long-help output (
src/cli/parser_tests.rs). The tests currently embedinsta::assert_snapshot!directly inside the test body, which causes irreversible filesystem I/O (reading or writing snapshot files) as an indistinguishable side-effect of what should be a pure query operation.Problem
insta'sassert_snapshot!macro unconditionally performs filesystem mutations during test execution. There is no clear boundary between:This violates the CQS principle and makes test intent harder to reason about.
Proposed resolution
Refactor the snapshot tests to separate concerns explicitly:
assert_snapshot!only from a clearly labelled snapshot-acceptance layer, or useinsta's explicitSettingsAPI (Settings::bind,Settings::set_snapshot_path, etc.) in a dedicated snapshot-acceptance test function that is clearly named and documented as having filesystem side-effects.References