Skip to content

test: consolidate divergent FakeChatClient doubles into a shared Netclaw.Tests.Utilities helper #1599

Description

@Aaronontheweb

Summary

Consolidate the divergent FakeChatClient test doubles into one shared helper in Netclaw.Tests.Utilities. Tracked follow-up to #1597 (whose fix intentionally added a small UsageOverride to the sub-agent FakeChatClient rather than blocking on this refactor).

Problem

There are three distinct classes literally named FakeChatClient, which have diverged in capability:

File Namespace Notable capabilities
src/Netclaw.Actors.Tests/Sessions/LlmSessionIntegrationTests.cs Netclaw.Actors.Tests.Sessions PlannedResponses, PlannedToolCallDecisions, UsageOverride, PlannedUsageOverrides, IncludeThinking, ObservationResponseOverride, … (feature-rich)
src/Netclaw.Actors.Tests/SubAgents/SubAgentActorTests.cs Netclaw.Actors.Tests.SubAgents ToolCallsOnFirstCall, ResponseTextsByCall, Delay, AlwaysReturnToolCalls, UsageOverride (added in #1597)
src/Netclaw.Daemon.Tests/Configuration/RetryingChatClientTests.cs Netclaw.Daemon.Tests.Configuration retry/failure-focused

The duplication is why #1597 had to re-add UsageOverride to the sub-agent fake even though the Sessions fake already had it — a "reuse before you add" violation the constitution flags.

Scope

  • In scope: unify the three FakeChatClient classes into a single configurable fake in Netclaw.Tests.Utilities (already referenced by Netclaw.Actors.Tests, Netclaw.Daemon.Tests, and others), then migrate call sites.
  • Out of scope: the ~15 bespoke, single-purpose fake IChatClient implementations (ParkingChatClient, ThrowingChatClient, SequencedToolCallChatClient, HangingStreamingChatClient, ControlledStreamingChatClient, StreamingTimeoutTestChatClient, ImageCapturingChatClient, …). These intentionally encode one behavior each; folding them into one mega-fake would be a worse abstraction. Leave them alone.

Acceptance

  • One FakeChatClient in Netclaw.Tests.Utilities covers the union of capabilities the three current copies need (streaming + non-streaming, tool calls, planned responses, per-call/override usage, thinking, delay).
  • Sessions / SubAgents / Daemon tests migrate onto it; the three duplicate definitions are deleted.
  • Full test suite stays green; no behavior change to production code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions