Skip to content

Snapshot localized CLI help output (#290)#326

Open
lodyai[bot] wants to merge 3 commits into
mainfrom
issue-290-snapshot-test-for-help-output
Open

Snapshot localized CLI help output (#290)#326
lodyai[bot] wants to merge 3 commits into
mainfrom
issue-290-snapshot-test-for-help-output

Conversation

@lodyai

@lodyai lodyai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

This branch adds regression coverage for issue #290 by snapshotting the
localised top-level CLI help output in en-US and es-ES. It directly
asserts that --config <FILE> is present with the Fluent-resolved
configuration-file description before storing the full rendered help text as
insta snapshots.

Closes #290.

Review walkthrough

Validation

  • cargo test localized_help_snapshots_include_config_flag --all-targets --all-features: passed.
  • make check-fmt: passed.
  • make lint: passed.
  • make test: passed.

Notes

  • coderabbit review --agent was attempted after the focused snapshot test, but the command stalled after reporting sandbox setup. The stalled process group from this worktree was stopped; no CodeRabbit findings were returned.
  • gh issue edit 290 --add-label low failed with GraphQL: Resource not accessible by integration, so the issue label could not be applied from this environment.

Summary by Sourcery

Add regression coverage to ensure localized CLI help output includes the configuration flag and is snapshotted for specific locales.

Tests:

  • Add parameterized test that snapshots localized CLI help output for en-US and es-ES and asserts presence of the config flag and its description.
  • Add insta snapshot files capturing the localized top-level CLI help output for English and Spanish locales.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@lodyai[bot], we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 15 minutes and 54 seconds. Learn how PR review limits work.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1ce72532-7de3-4820-8294-f8e57ee081ff

📥 Commits

Reviewing files that changed from the base of the PR and between 7888588 and 2eea7d6.

📒 Files selected for processing (1)
  • src/cli/parser_tests.rs

Walkthrough

Adds test harness wiring in parser.rs and implements snapshot-based localisation tests in parser_tests.rs using rstest parametrisation to validate CLI help output rendering of the --config flag with Fluent-localised descriptions across en-US and es-ES locales.

Changes

CLI Help Snapshot Tests

Layer / File(s) Summary
Localisation snapshot tests for CLI help
src/cli/parser.rs, src/cli/parser_tests.rs
Test module is wired into parser.rs via #[cfg(test)], and parser_tests.rs introduces a parametrised snapshot test using rstest that builds localisers for en-US and es-ES, renders help output, normalises Fluent isolates, asserts the --config <FILE> flag is present with the expected locale-specific description, and captures the full normalised help output via insta snapshots.

Snapshots and tests aligned, 📸
Help text for each locale signed,
English and Spanish combined,
Regressions won't hide away ✓
Localisation's bright pathway! 🌍


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (3 errors, 1 warning)

Check name Status Explanation Resolution
Module-Level Documentation ❌ Error The mod tests declaration in parser.rs (line 395-396) lacks module-level documentation. Although parser_tests.rs itself contains proper documentation, the module re-export must carry a docstr... Add a docstring above the #[cfg(test)] block documenting the tests module's purpose, utility and relationship to the parser module.
Unit Architecture ❌ Error The test embeds irreversible file I/O side-effects (snapshot writing) within apparently pure query operations without explicit API communication. Insta's assert_snapshot! hides filesystem mutations... Separate query (rendering/normalisation/assertion) from command (snapshot writing). Either use explicit snapshot management APIs or refactor to return normalised help for assertion outside the test, allowing callers to decide on snapshot...
Rust Compiler Lint Integrity ❌ Error The test creates intermediate String variables via format!() only to use them once in assertions, causing unnecessary heap allocations. Idiomatic Rust passes format arguments directly to assertion... Refactor assertions to pass format arguments directly: replace let missing_config_flag = format!(...); assert!(..., "{missing_config_flag}") with assert!(..., "...", locale) pattern.
Architectural Complexity And Maintainability ⚠️ Warning The PR adds simple, properly-scoped test code using established utilities without new abstractions. However, the review comment requesting inlined format arguments in assertions (lines 34–37) has n... Inline the format arguments directly into the assert! macro calls rather than pre-formatting into intermediate variables, as requested in the review.
✅ Passed checks (16 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Snapshot localized CLI help output (#290)' directly aligns with the PR's main objective of adding insta snapshots for localised CLI help and includes the linked issue reference.
Description check ✅ Passed The description comprehensively explains the regression test coverage for localised CLI help output, references the linked issue #290, and documents validation results.
Linked Issues check ✅ Passed The PR fully satisfies issue #290's requirements: parameterised test invokes CLI help for en-US and es-ES, asserts --config flag presence with Fluent-resolved description, and commits insta snapshots.
Out of Scope Changes check ✅ Passed All changes are scoped to adding regression test coverage for localised CLI help output; no unrelated alterations to runtime parsing logic or other subsystems are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Testing (Overall) ✅ Passed Test is substantive and rigorous: parameterised across locales, asserts flag presence + locale-specific descriptions, snapshots full help text. Would fail for all plausible incorrect implementation...
User-Facing Documentation ✅ Passed This PR adds regression test coverage (snapshot tests) for the existing --config flag introduced in PR #285. No new user-facing functionality or behaviour is introduced; the --config flag is alread...
Developer Documentation ✅ Passed PR adds regression tests for existing --config flag feature without introducing new internal APIs, architectural boundaries, tooling, or build requirements; no documentation updates are required.
Testing (Unit And Behavioural) ✅ Passed The PR adds a proper behavioural test that exercises the CLI help rendering boundary with real clap Command parsing and Fluent localisation, testing meaningful behaviour across locales with insta s...
Testing (Property / Proof) ✅ Passed PR adds snapshot tests for two fixed locales (en-US, es-ES), not testing invariants over a range of inputs; snapshot testing is appropriate for regression detection of deterministic CLI help output.
Testing (Compile-Time / Ui) ✅ Passed Snapshot tests are appropriate for UI text output. Test includes explicit pre-snapshot assertions for --config flag presence and Fluent-resolved description, plus comprehensive snapshots of rendere...
Domain Architecture ✅ Passed The PR adds CLI adapter layer tests only—help rendering snapshot tests with localization. No domain logic is imported or tested; domain boundaries remain clean with localization and help rendering...
Observability ✅ Passed PR adds only test code under #[cfg(test)] and snapshot files; does not introduce or alter operational behaviour, so observability requirements do not apply.
Security And Privacy ✅ Passed No secrets, credentials, sensitive paths, or privacy violations found. Test snapshots only public CLI help text using standard testing libraries with no file I/O or environment variable access.
Performance And Resource Use ✅ Passed The PR adds a parameterised snapshot test (2 locales) with bounded, O(n) operations where n=help_text_length (~3KB). No unbounded collections, unnecessary cloning, repeated I/O, nested loops, or al...
Concurrency And State ✅ Passed Test-only code with no concurrency patterns, async code, shared mutable state, locks, or ordering dependencies. Each rstest case independently builds fresh localizer and command instances.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #290

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-290-snapshot-test-for-help-output

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a parameterized, locale-aware CLI help snapshot test to ensure the localized help text includes the --config flag and its description, and introduces insta snapshots for en-US and es-ES outputs.

Sequence diagram for localized CLI help snapshot test

sequenceDiagram
    participant Test as localized_help_snapshots_include_config_flag
    participant Localizer as build_localizer
    participant Cli as Cli_command
    participant Localized as localize_command
    participant Normalizer as normalize_fluent_isolates
    participant Settings as snapshot_settings
    participant Insta as assert_snapshot

    Test->>Localizer: build_localizer(locale)
    Localizer-->>Test: localizer

    Test->>Cli: Cli::command()
    Cli-->>Test: command

    Test->>Localized: localize_command(command, localizer)
    Localized-->>Test: localized_command

    Test->>Localized: render_long_help()
    Localized-->>Test: rendered_help

    Test->>Normalizer: normalize_fluent_isolates(rendered_help)
    Normalizer-->>Test: normalized_help

    Test->>Test: assert contains("--config <FILE>")
    Test->>Test: assert contains(config_help)

    Test->>Settings: snapshot_settings("cli")
    Settings-->>Test: settings

    Test->>Settings: bind()
    activate Settings
    Settings->>Insta: assert_snapshot(snapshot_name, normalized_help)
    deactivate Settings
Loading

File-Level Changes

Change Details Files
Add a locale-parameterized snapshot test that asserts localized CLI help includes the --config flag and its localized description, then snapshots the full help output.
  • Introduce rstest-based parameterized test localized_help_snapshots_include_config_flag covering en-US and es-ES locales.
  • Build a localizer for each test case and apply it to the clap command via localize_command before rendering long help text.
  • Normalize Fluent isolation marks in the rendered help before assertions and snapshotting to avoid unstable artifacts.
  • Assert presence of the --config flag and its expected localized description in the normalized help output prior to snapshot comparison.
  • Use snapshot_settings("cli") to scope insta snapshot configuration and assert_snapshot! with per-locale snapshot names.
src/cli/mod.rs
Add insta snapshot files capturing the localized CLI help output for en-US and es-ES.
  • Create English CLI help snapshot file capturing the full normalized long help output for en-US.
  • Create Spanish CLI help snapshot file capturing the full normalized long help output for es-ES.
src/snapshots/cli/netsuke__cli__tests__help_en_us.snap
src/snapshots/cli/netsuke__cli__tests__help_es_es.snap

Assessment against linked issues

Issue Objective Addressed Explanation
#290 Add insta-based snapshot tests that invoke the CLI --help for each supported locale (at least en-US and es-ES) and assert that the --config flag and its localized description are present, while snapshotting the full help output.
#290 Store the new help output snapshots in the repository in an appropriate location alongside tests so regressions in flag naming, ordering, or localization are caught.
#290 Ensure these snapshot tests run in CI so that any divergence in rendered help text from the stored snapshots causes CI/test failures.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-delta-analysis[bot]

This comment was marked as outdated.

@lodyai lodyai Bot force-pushed the issue-290-snapshot-test-for-help-output branch from f209922 to ec8d068 Compare June 1, 2026 10:53
codescene-delta-analysis[bot]

This comment was marked as outdated.

@lodyai lodyai Bot force-pushed the issue-290-snapshot-test-for-help-output branch from ec8d068 to f782af9 Compare June 8, 2026 20:24
codescene-delta-analysis[bot]

This comment was marked as outdated.

Add `insta` coverage for localized top-level help in `en-US` and
`es-ES`. Assert the `--config` flag and resolved Fluent description
before snapshotting the full rendered help output so future CLI or
localisation drift is caught in review.
@lodyai lodyai Bot force-pushed the issue-290-snapshot-test-for-help-output branch from f782af9 to 7888588 Compare June 8, 2026 22:17
codescene-delta-analysis[bot]

This comment was marked as outdated.

@pandalump pandalump marked this pull request as ready for review June 12, 2026 10:56
@coderabbitai coderabbitai Bot added the Issue label Jun 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli/parser_tests.rs`:
- Around line 31-38: The two assertions in parser_tests.rs use a literal
"{locale}" instead of interpolating the locale variable; update both assertion
messages to format the locale (e.g., use "localized help for {} should include
the config flag" and pass locale as the format argument) so failures show the
actual locale value; change the messages associated with the assertions checking
normalized_help.contains("--config <FILE>") and
normalized_help.contains(config_help) to include locale via formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2ef37420-11f7-4fc0-b8b6-bf0de02b65ad

📥 Commits

Reviewing files that changed from the base of the PR and between ed38533 and 7888588.

⛔ Files ignored due to path filters (2)
  • src/snapshots/cli/netsuke__cli__parser__tests__help_en_us.snap is excluded by !**/*.snap
  • src/snapshots/cli/netsuke__cli__parser__tests__help_es_es.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/cli/parser.rs
  • src/cli/parser_tests.rs

Comment thread src/cli/parser_tests.rs
@leynos

leynos commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

Expand the parser snapshot test module documentation so its purpose and
coverage are clear, and make assertion failures report the locale under test.

Keep the change scoped to the still-valid snapshot-test diagnostics feedback.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/cli/parser_tests.rs (1)

31-38: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix assertion message formatting to interpolate the locale variable.

The assertion messages use {locale} within the string literal but do not pass locale as a format argument. When the assertion fails, the error message will display {locale} literally rather than showing which locale failed (en-US or es-ES). Fix both assertions to properly interpolate the variable for clearer test diagnostics.

Proposed fix
     assert!(
         normalized_help.contains("--config <FILE>"),
-        "localised help for {locale} should include the config flag"
+        "localised help for {} should include the config flag",
+        locale
     );
     assert!(
         normalized_help.contains(config_help),
-        "localised help for {locale} should include the config flag description"
+        "localised help for {} should include the config flag description",
+        locale
     );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/parser_tests.rs` around lines 31–38, the two assertions use a
literal `{locale}` instead of interpolating the locale variable; update both
assertion messages to format the locale (e.g., use "localised help for {}
should include the config flag" and pass locale as the format argument) so
failures show the actual locale value; change the messages associated with the
assertions checking `normalized_help.contains("--config <FILE>")` and
`normalized_help.contains(config_help)` to include locale via formatting.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/parser_tests.rs` around lines 31 - 38, The two assert macro calls in
the config flag validation section are using literal `{locale}` text in the
assertion messages instead of properly interpolating the locale variable. Fix
both assertions by changing the message strings to use Rust format string syntax
with `{}` placeholders and passing the `locale` variable as an argument to the
format macro (e.g., change the first assertion's message from "localized help
for {locale} should include the config flag" to "localized help for {} should
include the config flag" and add locale as the format argument). Apply the same
fix to the second assertion checking the config_help description so that test
failures will display the actual locale value rather than the literal string
{locale}.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@src/cli/parser_tests.rs`:
- Around line 31-38: The two assert macro calls in the config flag validation
section are using literal `{locale}` text in the assertion messages instead of
properly interpolating the locale variable. Fix both assertions by changing the
message strings to use Rust format string syntax with `{}` placeholders and
passing the `locale` variable as an argument to the format macro (e.g., change
the first assertion's message from "localized help for {locale} should include
the config flag" to "localized help for {} should include the config flag" and
add locale as the format argument). Apply the same fix to the second assertion
checking the config_help description so that test failures will display the
actual locale value rather than the literal string {locale}.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 74e10f1f-7080-40b3-ac11-307d60384384

📥 Commits

Reviewing files that changed from the base of the PR and between ed38533 and 7888588.

⛔ Files ignored due to path filters (2)
  • src/snapshots/cli/netsuke__cli__parser__tests__help_en_us.snap is excluded by !**/*.snap
  • src/snapshots/cli/netsuke__cli__parser__tests__help_es_es.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/cli/parser.rs
  • src/cli/parser_tests.rs

codescene-delta-analysis[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli/parser_tests.rs`:
- Around line 34-36: Remove the intermediate variable assignments for
missing_config_flag and missing_config_description that are created only to be
used once in assertions. Instead, inline the format! calls directly into the
assertion macros where these strings are used. Apply this same refactoring
pattern to the other occurrences at lines 40 and 44, eliminating intermediate
variables and using format arguments directly within the assertion macro
invocations for more idiomatic Rust code.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e8a2b12c-c1c6-49fd-9b8f-d3e2c6966790

📥 Commits

Reviewing files that changed from the base of the PR and between 7888588 and 8b9c67f.

📒 Files selected for processing (1)
  • src/cli/parser_tests.rs

Comment thread src/cli/parser_tests.rs Outdated
@leynos

leynos commented Jun 15, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

Remove one-use formatted strings from the localized help snapshot test so the
assertion messages use Rust's inline format capture directly.
@leynos

leynos commented Jun 16, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following failed checks now been resolved?

If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures.

Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope).

❌ Failed checks (3 errors, 1 warning)

Check name Status Explanation Resolution
Module-Level Documentation ❌ Error The mod tests declaration in parser.rs (line 395-396) lacks module-level documentation. Although parser_tests.rs itself contains proper documentation, the module re-export must carry a docstr... Add a docstring above the #[cfg(test)] block documenting the tests module's purpose, utility and relationship to the parser module.
Unit Architecture ❌ Error The test embeds irreversible file I/O side-effects (snapshot writing) within apparently pure query operations without explicit API communication. Insta's assert_snapshot! hides filesystem mutations... Separate query (rendering/normalisation/assertion) from command (snapshot writing). Either use explicit snapshot management APIs or refactor to return normalised help for assertion outside the test, allowing callers to decide on snapshot...
Rust Compiler Lint Integrity ❌ Error The test creates intermediate String variables via format!() only to use them once in assertions, causing unnecessary heap allocations. Idiomatic Rust passes format arguments directly to assertion... Refactor assertions to pass format arguments directly: replace let missing_config_flag = format!(...); assert!(..., "{missing_config_flag}") with assert!(..., "...", locale) pattern.
Architectural Complexity And Maintainability ⚠️ Warning The PR adds simple, properly-scoped test code using established utilities without new abstractions. However, the review comment requesting inlined format arguments in assertions (lines 34–37) has n... Inline the format arguments directly into the assert! macro calls rather than pre-formatting into intermediate variables, as requested in the review.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check current content of parser.rs around the mod tests declaration
cat src/cli/parser.rs | tail -20

echo "---"
# Check full content of parser_tests.rs
cat src/cli/parser_tests.rs

Length of output: 2401


🏁 Script executed:

#!/bin/bash
# Search for any existing issue covering unit architecture / snapshot I/O side-effects
gh issue list --repo leynos/netsuke --state open --search "snapshot architecture side-effect" --json number,title,url
gh issue list --repo leynos/netsuke --state open --search "unit architecture insta" --json number,title,url

Length of output: 375


🏁 Script executed:

#!/bin/bash
gh issue create \
  --repo leynos/netsuke \
  --title "Separate snapshot persistence from query logic in parser rendering tests" \
  --body "## 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:

1. Extract a pure helper function that returns the normalised rendered help string for a given locale.
2. Assert on the returned string in unit-style tests (no I/O).
3. 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

- PR `#326`: https://github.com/leynos/netsuke/pull/326
- Raised by `@leynos`
" \
  --assignee leynos

Length of output: 1682



@leynos: Here is the full picture.


Resolution summary

Check Status Action
Module-Level Documentation ❌ Open Agent prompt below — apply directly to this PR
Unit Architecture ❌ Open Tracked as #389 — out of scope for this PR
Rust Compiler Lint Integrity ✅ Resolved No further action needed
Architectural Complexity And Maintainability ✅ Resolved No further action needed

Check 1 — Module-Level Documentation: agent prompt

Apply this change to src/cli/parser.rs before merging:

File: src/cli/parser.rs

Locate the following block near the end of the file:

    #[cfg(test)]
    #[path = "parser_tests.rs"]
    mod tests;

Insert the following outer doc comment immediately above the `#[cfg(test)]`
attribute:

    /// Tests for the CLI parser's localisation rendering.
    ///
    /// Exercises locale-specific long-help output for the en-US and es-ES
    /// locales, asserts that `--config <FILE>` and its Fluent-resolved
    /// description are present, and pins the complete rendered help via Insta
    /// snapshots to detect regressions in flag naming, ordering, or
    /// localisation drift.
    #[cfg(test)]
    #[path = "parser_tests.rs"]
    mod tests;

Do not alter any other line. Verify with `make check-fmt` and `make lint`.

Check 2 — Unit Architecture: deferred to #389

No existing issue covered this concern. Issue #389 has been opened to track the refactoring of snapshot persistence out of the query path. No further action is required in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add insta snapshot test for --help output covering --config flag and Fluent-localised description (en-US + es-ES)

1 participant