Skip to content

Snapshot bump lockfile output and publish stale-lockfile errors (#81) - #119

Open
leynos wants to merge 1 commit into
mainfrom
issue-81-snapshot-lockfile-messages
Open

Snapshot bump lockfile output and publish stale-lockfile errors (#81)#119
leynos wants to merge 1 commit into
mainfrom
issue-81-snapshot-lockfile-messages

Conversation

@leynos

@leynos leynos commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #81

PR #75 introduced text-based CLI output for lockfile operations that was verified only by substring matching. New tests/unit/test_lockfile_message_snapshots.py adds syrupy snapshot coverage for all four cases:

  • Bump result message with a root Cargo.lock ((lockfile) suffix)
  • Bump result message including a nested tests/ui_lints/Cargo.lock
  • PublishPreflightError message for a single stale lockfile (with repair command)
  • PublishPreflightError message for multiple stale lockfiles

Snapshots use a fixed /ws workspace root so they stay deterministic.

Testing

  • make check-fmt, make lint, make typecheck, and make test (559 passed) all green.
  • coderabbit review --agent: 0 findings.

🤖 Generated with Claude Code

Summary by Sourcery

Add snapshot-based tests to lock in CLI output for lockfile bump and stale lockfile publish preflight messages.

Tests:

  • Add syrupy snapshot tests covering bump result messages with root and nested Cargo.lock files.
  • Add snapshot tests for publish preflight stale lockfile error messages for single and multiple lockfiles.

PR #75 introduced text-based CLI output for lockfile operations that
was verified only by substring matching: the (lockfile) suffix in
lading bump result messages and the multi-line stale-lockfile error
raised by lading publish.

Add syrupy snapshot coverage for all four cases: a bump message with a
root Cargo.lock, a bump message including a nested
tests/ui_lints/Cargo.lock, and the PublishPreflightError text for one
and for multiple stale lockfiles including their repair commands.

Closes #81
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Add Syrupy snapshot tests covering bump lockfile path messages and publish stale-lockfile errors for single and multiple lockfiles.

Changes

Lockfile message snapshot coverage

Layer / File(s) Summary
Bump message snapshots
tests/unit/test_lockfile_message_snapshots.py, tests/unit/__snapshots__/test_lockfile_message_snapshots.ambr
Add deterministic snapshots for root and nested Cargo.lock paths, including workspace-relative formatting and the (lockfile) suffix.
Stale-lockfile error snapshots
tests/unit/test_lockfile_message_snapshots.py, tests/unit/__snapshots__/test_lockfile_message_snapshots.ambr
Add snapshots for stale-lockfile errors containing repair instructions for single and multiple lockfiles.

Suggested labels: Issue

Suggested reviewers: codescene-access

Possibly related PRs

  • leynos/lading#160: Updates nested-lockfile discovery and stale Cargo.lock diagnostic wording covered by these snapshots.

Poem

Lockfiles speak in lines precise,
Snapshots guard their shifting guise.
Root paths shine, nested paths align,
Stale repairs print commands in line.
Four messages settle, crisp and bright.

🚥 Pre-merge checks | ✅ 20
✅ Passed checks (20 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #81 by adding snapshots for root and nested bump messages plus single and multiple stale-lockfile errors.
Out of Scope Changes check ✅ Passed Keep the changes in scope; only snapshot test files and expected outputs were added for the stated lockfile messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Testing (Overall) ✅ Passed The new snapshot tests exercise real formatter helpers with concrete root/nested and single/multiple cases, so plausible formatting regressions would fail.
User-Facing Documentation ✅ Passed PASS: The PR only adds snapshot tests and snapshot data; no user-facing behaviour changes ship, and the user guide already documents lockfile suffixes and stale-lockfile repairs.
Developer Documentation ✅ Passed No internal APIs, architecture, or tooling changed; only tests and snapshots were added, so no developer-guide update is needed.
Module-Level Documentation ✅ Passed Accept the module docstring; it explains the snapshot tests, their purpose, and their link to PR #75.
Testing (Unit And Behavioural) ✅ Passed PASS: The new snapshots pin exact root/nested lockfile and stale-lockfile formatting, while existing BDD scenarios already exercise the CLI boundary.
Testing (Property / Proof) ✅ Passed The PR adds fixed snapshot coverage for specific CLI strings; it does not introduce a range invariant or proof obligation, so property/proof testing is not required.
Testing (Compile-Time / Ui) ✅ Passed Approve this PR: the new snapshot tests pin the exact bump and stale-lockfile text, use a fixed /ws root, and cover the four required cases.
Unit Architecture ✅ Passed Tests target pure formatting helpers with explicit inputs; no new hidden I/O, state mutation, network, or command orchestration appears.
Domain Architecture ✅ Passed PASS: only unit snapshot tests changed; no domain model code moved or leaked infrastructure concerns into domain entities.
Observability ✅ Passed Pass: the commit only adds snapshot tests and snapshots; it introduces no production logging, metrics, tracing, or alerts to assess.
Security And Privacy ✅ Passed Inspect the new snapshot tests and snapshots: they use fake /ws paths, no credentials, and only assert formatting output; no security- or privacy-sensitive exposure appears.
Performance And Resource Use ✅ Passed PASS: limit the change to small snapshot tests; no new hot-path loops, I/O, unbounded collections, or growth risks in production code.
Concurrency And State ✅ Passed Only snapshot tests and immutable Path constants were added; no shared mutable state, locks, async tasks, or ordering-sensitive code changed.
Architectural Complexity And Maintainability ✅ Passed PASS: Keep this as a small, explicit test-only change; it adds no new production abstractions, layers, registries, or hidden lifecycle hooks.
Rust Compiler Lint Integrity ✅ Passed Only Python test/snapshot files changed; no Rust sources, lint suppressions, dead-code anchors, or clone-heavy code were introduced.
Title check ✅ Passed The title matches the lockfile snapshot test changes and includes the linked issue number.
Description check ✅ Passed The description clearly describes the new snapshot coverage for lockfile-related CLI output.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-81-snapshot-lockfile-messages

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

@sourcery-ai

sourcery-ai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds deterministic syrupy snapshot tests to validate CLI lockfile-related output formats for bump and publish preflight operations, covering root vs nested Cargo.lock handling and single vs multiple stale lockfile errors.

File-Level Changes

Change Details Files
Add syrupy snapshot coverage for lockfile-related CLI output from bump and publish preflight commands.
  • Introduce a dedicated test module that constructs BumpChanges with a fixed /ws workspace root and exercises bump._format_result_message for configurations with root-only and root+nested Cargo.lock files.
  • Add snapshot tests validating _build_stale_lockfile_message output for single and multiple stale lockfiles, including per-file repair commands and formatting.
  • Configure snapshots via a new .ambr snapshot file to lock in the exact multiline text output for all four scenarios.
tests/unit/test_lockfile_message_snapshots.py
tests/unit/__snapshots__/test_lockfile_message_snapshots.ambr

Assessment against linked issues

Issue Objective Addressed Explanation
#81 Add syrupy snapshot test for bump result message with a root Cargo.lock (lockfile suffix).
#81 Add syrupy snapshot test for bump result message with a nested tests/ui_lints/Cargo.lock.
#81 Add syrupy snapshot tests for PublishPreflightError messages for stale lockfiles: one test for a single stale lockfile and one test for multiple stale lockfiles.

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

@leynos
leynos marked this pull request as ready for review July 27, 2026 21:57
@coderabbitai coderabbitai Bot added the Issue label Jul 27, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The tests rely on private helpers (bump._format_result_message, _build_stale_lockfile_message), which may change frequently; consider routing through the public CLI interface or adding a thin public wrapper to reduce brittleness.
  • The stale lockfile tests are very similar; you could use a parametrized test (single vs multiple lockfiles) to reduce duplication while keeping snapshot coverage intact.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The tests rely on private helpers (`bump._format_result_message`, `_build_stale_lockfile_message`), which may change frequently; consider routing through the public CLI interface or adding a thin public wrapper to reduce brittleness.
- The stale lockfile tests are very similar; you could use a parametrized test (single vs multiple lockfiles) to reduce duplication while keeping snapshot coverage intact.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@tests/unit/test_lockfile_message_snapshots.py`:
- Line 40: Update every snapshot assertion comparing snapshot with
_result_message(changes) in the lockfile message tests to include a concise,
case-specific assertion message identifying whether the scenario is root,
nested, single-lockfile, or multiple-lockfile. Apply this consistently to all
four assertions while preserving their existing comparisons.
- Around line 33-70: The four repeated snapshot tests should be consolidated
into parametrized pytest cases, grouped in a focused test class where
appropriate. Parameterize the bump-message scenarios with stable IDs such as
root and nested, and the stale-lockfile scenarios with single and multiple;
preserve each existing input setup, snapshot assertion, and test behavior.
🪄 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: 1a96614f-053d-4344-834b-3367bd58a6d9

📥 Commits

Reviewing files that changed from the base of the PR and between a07962b and 61e62bd.

📒 Files selected for processing (2)
  • tests/unit/__snapshots__/test_lockfile_message_snapshots.ambr
  • tests/unit/test_lockfile_message_snapshots.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/cmd-mox (auto-detected)
  • leynos/cuprum (auto-detected)
  • leynos/shared-actions (auto-detected)

Comment on lines +33 to +70
def test_bump_message_with_root_lockfile(snapshot: SnapshotAssertion) -> None:
"""A workspace-root Cargo.lock is listed with the (lockfile) suffix."""
changes = bump.BumpChanges(
manifests=(_WORKSPACE_ROOT / "Cargo.toml",),
lockfiles=(_WORKSPACE_ROOT / "Cargo.lock",),
)

assert snapshot == _result_message(changes)


def test_bump_message_with_nested_lockfile(snapshot: SnapshotAssertion) -> None:
"""A nested Cargo.lock renders relative to the workspace root."""
changes = bump.BumpChanges(
manifests=(_WORKSPACE_ROOT / "Cargo.toml",),
lockfiles=(
_WORKSPACE_ROOT / "Cargo.lock",
_WORKSPACE_ROOT / "tests" / "ui_lints" / "Cargo.lock",
),
)

assert snapshot == _result_message(changes)


def test_stale_lockfile_error_single(snapshot: SnapshotAssertion) -> None:
"""A single stale lockfile lists one repair command."""
message = _build_stale_lockfile_message([_WORKSPACE_ROOT / "Cargo.lock"])

assert snapshot == message


def test_stale_lockfile_error_multiple(snapshot: SnapshotAssertion) -> None:
"""Multiple stale lockfiles each list their own repair command."""
message = _build_stale_lockfile_message([
_WORKSPACE_ROOT / "Cargo.lock",
_WORKSPACE_ROOT / "tests" / "ui_lints" / "Cargo.lock",
])

assert snapshot == message

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Parameterize the repeated snapshot cases.

Replace the two bump tests and two stale-lockfile tests with parametrized cases, retaining stable IDs such as root, nested, single, and multiple. Group related cases in a focused pytest class where appropriate.

🤖 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 `@tests/unit/test_lockfile_message_snapshots.py` around lines 33 - 70, The four
repeated snapshot tests should be consolidated into parametrized pytest cases,
grouped in a focused test class where appropriate. Parameterize the bump-message
scenarios with stable IDs such as root and nested, and the stale-lockfile
scenarios with single and multiple; preserve each existing input setup, snapshot
assertion, and test behavior.

Sources: Coding guidelines, Path instructions

lockfiles=(_WORKSPACE_ROOT / "Cargo.lock",),
)

assert snapshot == _result_message(changes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add messages to every snapshot assertion.

Change each bare assertion to include a concise case-specific message identifying the root, nested, single, or multiple-lockfile scenario.

Also applies to: 53-53, 60-60, 70-70

🤖 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 `@tests/unit/test_lockfile_message_snapshots.py` at line 40, Update every
snapshot assertion comparing snapshot with _result_message(changes) in the
lockfile message tests to include a concise, case-specific assertion message
identifying whether the scenario is root, nested, single-lockfile, or
multiple-lockfile. Apply this consistently to all four assertions while
preserving their existing comparisons.

Source: Path instructions

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 syrupy snapshot tests for bump lockfile messages and publish stale-lockfile errors

1 participant