Snapshot bump lockfile output and publish stale-lockfile errors (#81) - #119
Snapshot bump lockfile output and publish stale-lockfile errors (#81)#119leynos wants to merge 5 commits into
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
SummaryAdd Syrupy snapshot coverage for lockfile-related CLI output.
All 559 tests, formatting, linting, and type checks pass. WalkthroughAdd Syrupy snapshot tests for ChangesLockfile message snapshot coverage
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 19 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (19 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideAdds 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
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
tests/unit/__snapshots__/test_lockfile_message_snapshots.ambrtests/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)
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
Group the bump and stale-lockfile message scenarios into focused parametrized tests. Give every snapshot comparison a case-specific failure message while preserving the existing output contracts.
Exercise the public `bump.run` and `publish.run` boundaries when snapshotting lockfile output. Keep external lockfile operations controlled without coupling the assertions to private formatters.
Restore real publish preflight through its relocated module and stub the new lockfile inspection adapter boundary. Refresh stale-lockfile snapshots to retain main's expanded repair guidance after the rebase.
2dcf73c to
d58a544
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai Have the following now been resolved?
|
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Excess Number of Function Argumentstests/unit/test_lockfile_message_snapshots.py: TestBumpLockfileMessages.test_message What lead to degradation?TestBumpLockfileMessages.test_message has 5 arguments, max arguments = 4 Why does this problem occur?Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments. How to fix it?Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring INTRODUCE PARAMETER OBJECT to encapsulate arguments that refer to the same logical concept. Helpful refactoring examplesThis code health issue has been solved before in this project. Here are some examples for inspiration: undefined# conftest.py (114b752)
def publish_fixtures(
- tmp_path: Path,
- make_crate: typ.Callable[[Path, str, _CrateSpec | None], WorkspaceCrate],
- make_workspace: typ.Callable[[Path, WorkspaceCrate], WorkspaceGraph],
- make_config: typ.Callable[..., config_module.LadingConfig],
- make_dependency: typ.Callable[[str], WorkspaceDependency],
- publish_options: publish.PublishOptions,
+ request: pytest.FixtureRequest, publish_options: publish.PublishOptions
) -> PublishFixtures:
"""Return the composite publish fixtures used across unit suites."""
+ tmp_path: Path = request.getfixturevalue("tmp_path")
+ make_crate = request.getfixturevalue("make_crate")
+ make_workspace = request.getfixturevalue("make_workspace")
+ make_config = request.getfixturevalue("make_config")
+ make_dependency = request.getfixturevalue("make_dependency")
return PublishFixtures( |
This comment was marked as resolved.
This comment was marked as resolved.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
ast-grep outline tests/unit/test_lockfile_message_snapshots.py --items all
ast-grep outline tests/unit/conftest.py --items all --match 'enable_publish_preflight|disable_publish_preflight'
printf '\n--- private-helper references and public command calls ---\n'
rg -n -C 4 '(_format_result_message|_build_stale_lockfile_message|\bbump\.run\s*\(|\bpublish\.run\s*\()' \
tests/unit/test_lockfile_message_snapshots.py
printf '\n--- stale-lockfile test implementation ---\n'
rg -n -A 100 -B 12 'class\s+TestStaleLockfileMessages|def\s+test_message\s*\(' \
tests/unit/test_lockfile_message_snapshots.pyLength of output: 6579
You are interacting with an AI system. |
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Excess Number of Function Argumentstests/unit/test_lockfile_message_snapshots.py: TestStaleLockfileMessages.test_message What lead to degradation?TestStaleLockfileMessages.test_message has 5 arguments, max arguments = 4 Why does this problem occur?Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments. How to fix it?Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring INTRODUCE PARAMETER OBJECT to encapsulate arguments that refer to the same logical concept. Helpful refactoring examplesThis code health issue has been solved before in this project. Here are some examples for inspiration: undefined# conftest.py (114b752)
def publish_fixtures(
- tmp_path: Path,
- make_crate: typ.Callable[[Path, str, _CrateSpec | None], WorkspaceCrate],
- make_workspace: typ.Callable[[Path, WorkspaceCrate], WorkspaceGraph],
- make_config: typ.Callable[..., config_module.LadingConfig],
- make_dependency: typ.Callable[[str], WorkspaceDependency],
- publish_options: publish.PublishOptions,
+ request: pytest.FixtureRequest, publish_options: publish.PublishOptions
) -> PublishFixtures:
"""Return the composite publish fixtures used across unit suites."""
+ tmp_path: Path = request.getfixturevalue("tmp_path")
+ make_crate = request.getfixturevalue("make_crate")
+ make_workspace = request.getfixturevalue("make_workspace")
+ make_config = request.getfixturevalue("make_config")
+ make_dependency = request.getfixturevalue("make_dependency")
return PublishFixtures( |
This comment was marked as resolved.
This comment was marked as resolved.
Use the parametrized test IDs as the sole case labels so the test methods do not carry unused scenario arguments.
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.pyadds syrupy snapshot coverage for all four cases:Cargo.lock((lockfile)suffix)tests/ui_lints/Cargo.lockPublishPreflightErrormessage for a single stale lockfile (with repair command)PublishPreflightErrormessage for multiple stale lockfilesSnapshots use a fixed
/wsworkspace root so they stay deterministic.Testing
make check-fmt,make lint,make typecheck, andmake 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:
References