package main import ( "path/filepath" "testing" "time" "github.com/stretchr/testify/require" ) // newTestIdleTurnLoop opens a loop with no model calls or turn goroutine. // Callers can test queued messages and events with synctest fake time. func newTestIdleTurnLoop(t *testing.T, whatsapp *WhatsApp) (*TurnLoop, *TurnEventRecorder) { t.Helper() agent, err := openAgent(t.TempDir()) require.NoError(t, err) memory, err := openMemory(t.Context(), agent.dir, time.Now, newFakeSummarizer(), discardLog()) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, memory.Close()) }) events := &TurnEventRecorder{} client := newModelClient("https://example.com", ModelAPIKey(modelTestKey), agent.CacheKey(), filepath.Join(agent.dir, "usage.jsonl")) loop, err := newTurnLoop(agent, memory, newTestSubagents(t), whatsapp, newTestSchedules(t, time.Now), client, time.Now, discardLog(), events.Add) require.NoError(t, err) return loop, events }