Skip to content

Add snapshot tests for CircularDependency formatting (#332)#361

Draft
leynos wants to merge 1 commit into
mainfrom
issue-332-circular-dependency-snapshots
Draft

Add snapshot tests for CircularDependency formatting (#332)#361
leynos wants to merge 1 commit into
mainfrom
issue-332-circular-dependency-snapshots

Conversation

@leynos

@leynos leynos commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #332

Adds insta snapshot coverage for the user-facing IrGenError::CircularDependency message, following the established diagnostic_json_tests pattern (localiser lock + set_en_localizer + assert_snapshot!).

  • circular_dependency_display — snapshots the Display rendering (Circular dependency detected: ["a", "b", "a"].).
  • circular_dependency_error_json — snapshots the JSON diagnostic document via render_error_json (the plain-error path; IrGenError does not implement miette::Diagnostic, so render_diagnostic_json does not apply).

The error is produced through the real pipeline (manifest::from_strBuildGraph::from_manifest) with a two-target cycle; the detector's canonical rotation keeps the snapshot deterministic.

Validation

  • make check-fmt / make lint / make test — pass (37 suites; both snapshots committed and green)

🤖 Generated with Claude Code

Summary by Sourcery

Add snapshot-based regression tests for the CircularDependency IR generation error formatting.

Tests:

  • Add snapshot test for the Display output of IrGenError::CircularDependency built via the real IR pipeline.
  • Add snapshot test for the JSON error document produced for IrGenError::CircularDependency using render_error_json().

Pin the user-facing output of `IrGenError::CircularDependency` with
insta snapshots, following the localiser-lock pattern established in
`src/diagnostic_json_tests.rs`:

- `circular_dependency_display` captures the `Display` rendering of
  the localised message for a deterministic two-target cycle;
- `circular_dependency_error_json` captures the JSON diagnostic
  document produced by `render_error_json` for the same error.

The error is constructed through the real pipeline (manifest →
`BuildGraph::from_manifest`), and the cycle detector's canonical
rotation keeps the reported sequence stable.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e759570b-b1ee-462f-b808-96c2a8bb4ebc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-332-circular-dependency-snapshots

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

@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds snapshot-based regression tests for the user-facing IrGenError::CircularDependency formatting (Display and JSON), using the existing diagnostic_json_tests insta test harness and a deterministic circular manifest built through the real IR pipeline.

File-Level Changes

Change Details Files
Add insta snapshot tests for IrGenError::CircularDependency Display and JSON output using the diagnostic_json_tests harness and a deterministic circular manifest.
  • Introduce helper function that constructs a manifest with two mutually dependent targets and builds the IR to yield a real IrGenError::CircularDependency via BuildGraph::from_manifest
  • Add rstest-based snapshot test that locks localization, forces English localizer, and snapshots the error Display string using assert_snapshot! and snapshot_settings
  • Add rstest-based snapshot test that renders the error to JSON via render_error_json, normalizes it through parse_json_value and serde_json::to_string_pretty, and snapshots the pretty JSON output
  • Commit two new insta snapshot files under src/snapshots/diagnostic_json for the Display string and JSON diagnostic outputs respectively
src/diagnostic_json_tests.rs
src/snapshots/diagnostic_json/netsuke__diagnostic_json__tests__circular_dependency_display.snap
src/snapshots/diagnostic_json/netsuke__diagnostic_json__tests__circular_dependency_error_json.snap

Assessment against linked issues

Issue Objective Addressed Explanation
#332 Add insta snapshot tests in diagnostic_json_tests.rs for the formatted Display output of IrGenError::CircularDependency, following the existing localiser lock + set_en_localizer + assert_snapshot! pattern.
#332 Add insta snapshot tests in diagnostic_json_tests.rs for the JSON diagnostic output of IrGenError::CircularDependency (via the error JSON renderer), following the existing snapshot pattern and using a representative cyclic manifest.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add insta snapshot tests for CircularDependency error message formatting

1 participant