Update pkg/agent/loop_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Kristjan Kruus 2026-03-24 20:51:56 +02:00 committed by GitHub
parent 753b5d981f
commit 04411bd55d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2166,15 +2166,22 @@ func TestProcessHeartbeat_RunsWhenIdle(t *testing.T) {
} }
// ProcessHeartbeat should proceed (not return early with HEARTBEAT_OK skip) // ProcessHeartbeat should proceed (not return early with HEARTBEAT_OK skip)
// It will either succeed or fail depending on agent setup, but it should NOT // and, with the mock provider used in newTestAgentLoop, return a deterministic
// return the skip sentinel. // mock response.
resp, err := al.ProcessHeartbeat(context.Background(), "heartbeat prompt", "cli", "direct") resp, err := al.ProcessHeartbeat(context.Background(), "heartbeat prompt", "cli", "direct")
// With no default agent registered, it returns an error — that's fine, // Must not skip due to busy check.
// the point is it didn't skip due to busy check. if resp == "HEARTBEAT_OK" {
if err != nil && resp == "HEARTBEAT_OK" {
t.Fatal("ProcessHeartbeat skipped despite no active turns") 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) { func TestProcessHeartbeat_SkipsForAnyActiveSession(t *testing.T) {