From 04411bd55dc21d0137b8df4ce175a62aa22d982c Mon Sep 17 00:00:00 2001 From: Kristjan Kruus Date: Tue, 24 Mar 2026 20:51:56 +0200 Subject: [PATCH] Update pkg/agent/loop_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pkg/agent/loop_test.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/agent/loop_test.go b/pkg/agent/loop_test.go index 1d05aedce..f4503740d 100644 --- a/pkg/agent/loop_test.go +++ b/pkg/agent/loop_test.go @@ -2166,15 +2166,22 @@ func TestProcessHeartbeat_RunsWhenIdle(t *testing.T) { } // ProcessHeartbeat should proceed (not return early with HEARTBEAT_OK skip) - // It will either succeed or fail depending on agent setup, but it should NOT - // return the skip sentinel. + // and, with the mock provider used in newTestAgentLoop, return a deterministic + // mock response. resp, err := al.ProcessHeartbeat(context.Background(), "heartbeat prompt", "cli", "direct") - // With no default agent registered, it returns an error — that's fine, - // the point is it didn't skip due to busy check. - if err != nil && resp == "HEARTBEAT_OK" { + // Must not skip due to busy check. + if resp == "HEARTBEAT_OK" { t.Fatal("ProcessHeartbeat skipped despite no active turns") } + + // Given the mock provider, the heartbeat call should succeed with a fixed response. + if err != nil { + t.Fatalf("expected no error from ProcessHeartbeat when idle, got: %v", err) + } + if resp != "Mock response" { + t.Fatalf("expected mock provider response %q, got %q", "Mock response", resp) + } } func TestProcessHeartbeat_SkipsForAnyActiveSession(t *testing.T) {