Skip to content

🧪 Add tests for RecoverableError::allows_partial and is_retryable#120

Open
bashandbone wants to merge 4 commits intomainfrom
test/recoverable-error-allows-partial-13292274821357028093
Open

🧪 Add tests for RecoverableError::allows_partial and is_retryable#120
bashandbone wants to merge 4 commits intomainfrom
test/recoverable-error-allows-partial-13292274821357028093

Conversation

@bashandbone
Copy link
Contributor

@bashandbone bashandbone commented Mar 22, 2026

🎯 What: The testing gap addressed: added tests for the default allows_partial and is_retryable methods in the RecoverableError trait.
📊 Coverage: What scenarios are now tested: allows_partial is explicitly verified against all variants of RecoveryStrategy (Partial, Skip, Retry, Fallback, Abort) and None to ensure it only returns true for Partial and Skip. The same comprehensive enumeration is also tested for is_retryable checking for the Retry variant.
Result: The improvement in test coverage: ensuring error recovery behavior is explicitly asserted for future regressions.


PR created automatically by Jules for task 13292274821357028093 started by @bashandbone

Summary by Sourcery

Add unit tests to verify default RecoverableError behavior for retryable and partial recovery scenarios.

Tests:

  • Add tests covering is_retryable across all RecoveryStrategy variants and absence of recovery info.
  • Add tests covering allows_partial across all RecoveryStrategy variants and absence of recovery info.

…tial and is_retryable

Adds a new `MockRecoverableError` struct in the `error.rs` tests module to instantiate and test the `RecoveryStrategy` logic for the default `RecoverableError::allows_partial` and `RecoverableError::is_retryable` methods. Ensures that `Partial` and `Skip` are correctly identified for `allows_partial()` and `Retry` is correctly identified for `is_retryable()`.

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings March 22, 2026 20:28
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 22, 2026

Reviewer's Guide

Adds focused unit tests for the default RecoverableError::is_retryable and allows_partial behavior by introducing a simple mock RecoverableError implementation and exercising all RecoveryStrategy variants plus the None case.

Class diagram for RecoverableError and MockRecoverableError tests

classDiagram
    class RecoverableError {
        +recovery_info() Option_ErrorRecovery
        +is_retryable() bool
        +allows_partial() bool
    }

    class MockRecoverableError {
        -recovery Option_ErrorRecovery
        +MockRecoverableError(recovery Option_ErrorRecovery)
        +recovery_info() Option_ErrorRecovery
    }

    class ErrorRecovery {
        +strategy RecoveryStrategy
        +instructions String
        +auto_recoverable bool
    }

    class RecoveryStrategy {
    }

    class RecoveryStrategy_Partial
    class RecoveryStrategy_Skip
    class RecoveryStrategy_Retry {
        +max_attempts int
    }
    class RecoveryStrategy_Fallback {
        +strategy String
    }
    class RecoveryStrategy_Abort

    RecoverableError <|.. MockRecoverableError
    ErrorRecovery --> RecoveryStrategy
    MockRecoverableError --> ErrorRecovery

    RecoveryStrategy <|-- RecoveryStrategy_Partial
    RecoveryStrategy <|-- RecoveryStrategy_Skip
    RecoveryStrategy <|-- RecoveryStrategy_Retry
    RecoveryStrategy <|-- RecoveryStrategy_Fallback
    RecoveryStrategy <|-- RecoveryStrategy_Abort
Loading

Flow diagram for is_retryable and allows_partial decision logic

flowchart TD
    A[Start: RecoverableError instance] --> B{Has recovery_info}
    B -->|None| C_is[is_retryable returns false]
    B -->|None| C_ap[allows_partial returns false]

    B -->|Some ErrorRecovery| D{strategy}

    D -->|Retry| E_is_true[is_retryable returns true]
    D -->|Retry| E_ap_false[allows_partial returns false]

    D -->|Partial| F_is_false_p[is_retryable returns false]
    D -->|Partial| F_ap_true[allows_partial returns true]

    D -->|Skip| G_is_false_s[is_retryable returns false]
    D -->|Skip| G_ap_true[allows_partial returns true]

    D -->|Fallback| H_is_false_f[is_retryable returns false]
    D -->|Fallback| H_ap_false_f[allows_partial returns false]

    D -->|Abort| I_is_false_a[is_retryable returns false]
    D -->|Abort| I_ap_false_a[allows_partial returns false]

    C_is --> Z[End]
    C_ap --> Z
    E_is_true --> Z
    E_ap_false --> Z
    F_is_false_p --> Z
    F_ap_true --> Z
    G_is_false_s --> Z
    G_ap_true --> Z
    H_is_false_f --> Z
    H_ap_false_f --> Z
    I_is_false_a --> Z
    I_ap_false_a --> Z
Loading

File-Level Changes

Change Details Files
Introduce a mock RecoverableError implementation to drive tests for default trait methods.
  • Add MockRecoverableError wrapper type holding an optional ErrorRecovery
  • Implement RecoverableError for MockRecoverableError by delegating recovery_info to its inner Option
  • Add create_mock_error helper to construct MockRecoverableError instances with a given RecoveryStrategy and fixed metadata
crates/services/src/error.rs
Add exhaustive tests for RecoverableError::is_retryable across all RecoveryStrategy variants and the None case.
  • Create a retryable MockRecoverableError using RecoveryStrategy::Retry and assert is_retryable returns true
  • Create non-retryable MockRecoverableError values for Skip, Fallback, Abort, Partial and assert is_retryable returns false
  • Construct a MockRecoverableError with None recovery info and assert is_retryable returns false
crates/services/src/error.rs
Add exhaustive tests for RecoverableError::allows_partial across all RecoveryStrategy variants and the None case.
  • Create MockRecoverableError values for Partial and Skip and assert allows_partial returns true
  • Create MockRecoverableError values for Retry, Fallback, Abort and assert allows_partial returns false
  • Construct a MockRecoverableError with None recovery info and assert allows_partial returns false
crates/services/src/error.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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

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 test_is_retryable and test_allows_partial cases are quite repetitive; consider using a table-driven approach (e.g., iterating over (strategy, expected) pairs) to make the tests more compact and easier to extend.
  • You can reuse common ErrorRecovery fields (like instructions and auto_recoverable) via a single helper or constant to avoid repeating the same literals in each create_mock_error call.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `test_is_retryable` and `test_allows_partial` cases are quite repetitive; consider using a table-driven approach (e.g., iterating over `(strategy, expected)` pairs) to make the tests more compact and easier to extend.
- You can reuse common `ErrorRecovery` fields (like `instructions` and `auto_recoverable`) via a single helper or constant to avoid repeating the same literals in each `create_mock_error` call.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds unit tests to close a coverage gap around the default helper methods on the RecoverableError trait, ensuring recovery behavior is explicitly asserted and guarded against regressions.

Changes:

  • Added a mock RecoverableError implementation for testing default trait methods.
  • Added comprehensive tests for RecoverableError::is_retryable across all RecoveryStrategy variants plus None.
  • Added comprehensive tests for RecoverableError::allows_partial across all RecoveryStrategy variants plus None.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

google-labs-jules bot and others added 3 commits March 22, 2026 20:34
Fixes a compiler error `E0425: cannot find value file_name in this scope` caused by declaring `_file_name` but referencing `file_name` in `crates/language/src/lib.rs`.

Also includes previous test improvements:
test: add tests for RecoverableError default trait methods allows_partial and is_retryable

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Updates several examples in thread-ast-engine rustdocs that broke when upstream ast-grep trait constraints (like Clone and Debug for Language, or Document changes) were modified. This fixes the CI 'Test' suite failures. Also implements `Clone` and `Debug` on `Tsx` and `JavaScript` test languages.

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
…rates

Fixes additional doc tests across `crates/ast-engine/src/*` where trailing `}` or missing variable scope issues were introduced from previous fixes.
Also fixes `crates/language/src/lib.rs` and `html.rs` tests failing due to missing trait imports like `thread_ast_engine::tree_sitter::LanguageExt` and `Doc` when calling `ast_grep`.

Test pass rates across `thread-ast-engine` and `thread-language` crates should now succeed.

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
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.

2 participants