Skip to content

Centralize component install failure message in tests#222

Draft
leynos wants to merge 1 commit into
mainfrom
improve-error-handling-jsppmt
Draft

Centralize component install failure message in tests#222
leynos wants to merge 1 commit into
mainfrom
improve-error-handling-jsppmt

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Apr 23, 2026

Summary

  • Centralizes the component install failure message into a shared constant and uses it across tests to improve error handling verification and reduce brittle string literals.

Changes

Testing

  • Add COMPONENT_INSTALL_FAILURE_MESSAGE constant in installer/src/toolchain/tests/failure_mocks.rs
  • Use COMPONENT_INSTALL_FAILURE_MESSAGE in setup_component_add_failure_mocks_inner when returning stderr output
  • Update is_component_install_failed to check for COMPONENT_INSTALL_FAILURE_MESSAGE
  • Update tests in installer/src/toolchain/tests/mod.rs to import and reference COMPONENT_INSTALL_FAILURE_MESSAGE instead of the literal string
  • Adjust test expectations to use the new constant

Why

  • Removes duplication and potential drift between tests by consolidating the failure message into a single shared constant
  • Improves maintainability and robustness of error handling verification in tests

Test plan

  • Run cargo test (workspace) to ensure all tests pass, with emphasis on toolchain/install-related tests
  • Specifically verify tests that previously asserted on the string "component failed" now use the centralized constant

Notes

  • The COMPONENT_INSTALL_FAILURE_MESSAGE constant is pub(super) to restrict visibility to the test module scope
  • No production code behavior changed; this is a test-only refactor to improve reliability and readability

◳ Generated by DevBoxer


ℹ️ Tag @devboxerhub to ask questions and address PR feedback

📎 Task: https://www.devboxer.com/task/3af976c2-4ae8-40dc-9702-a8f52931adee

Summary by Sourcery

Tests:

  • Introduce a shared COMPONENT_INSTALL_FAILURE_MESSAGE constant for mocked stderr output in toolchain installer tests and update assertions and helpers to use it.

… in tests

Extracted a constant COMPONENT_INSTALL_FAILURE_MESSAGE for the failure message string used in component installation failure mocks and assertions. This reduces duplication and improves maintainability of failure test code.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

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

Run ID: 9e6b59f0-51f3-4c9f-a2bd-1dfecea39f46

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 improve-error-handling-jsppmt

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

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 23, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Centralizes the component install failure message into a single shared constant used by failure mocks and assertions in toolchain installer tests, improving consistency and reducing duplicated string literals.

File-Level Changes

Change Details Files
Introduce a shared constant for the component install failure message and use it in failure mocks and helper logic.
  • Define pub(super) COMPONENT_INSTALL_FAILURE_MESSAGE constant holding the failure message string
  • Update mocked command runner setup to return stderr using the shared constant
  • Update is_component_install_failed helper to check message contents using the shared constant instead of a literal
installer/src/toolchain/tests/failure_mocks.rs
Update toolchain installer tests to rely on the shared failure message constant instead of hard-coded strings.
  • Import and use COMPONENT_INSTALL_FAILURE_MESSAGE when constructing failing command runner output
  • Adjust error pattern-matching assertions to check message contents using the shared constant
installer/src/toolchain/tests/mod.rs

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.

1 participant