Skip to content

test(agent): add cancellation coverage for apply_response_cache cleanup loop #4587

@bug-ops

Description

@bug-ops

Description

The cancellation path added in #4572 (the `cancel.cancelled()` branch inside `tokio::select!` in `apply_response_cache`) has zero test coverage. The two existing tests at `src/agent_setup.rs:1708` and `src/agent_setup.rs:1720` pass a `CancellationToken` but never cancel it, so the early-exit branch is never exercised.

Expected Behavior

A dedicated test cancels the token during an active cleanup interval and asserts the task exits promptly.

Actual Behavior

The structural correctness of the fix was verified by code review, but the cancel branch is never reached in the test suite.

Suggested Test

#[tokio::test]
async fn apply_response_cache_cleanup_exits_on_cancel() {
    let cancel = CancellationToken::new();
    let handle = apply_response_cache(/* minimal args */, cancel.clone());
    cancel.cancel();
    tokio::time::timeout(Duration::from_secs(1), handle)
        .await
        .expect("cleanup task did not exit on cancellation");
}

Environment

Metadata

Metadata

Assignees

Labels

P3Research — medium-high complexityenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions