]> git.giacomolli.uk - onechat/blobdiff - turn_test.go
Log Telegram outages once in plain words
[onechat] / turn_test.go
index 69c9236081ba743fd49ab88d55a3c403767a7efe..1d958565550ba81be1fdfb4790460a3d7ac9d1ca 100644 (file)
@@ -170,7 +170,7 @@ func TestTurnWaitsForTheSummaries(t *testing.T) {
        close(summarizer.gate)
        test.events.WaitFor(t, "idle", 1)
        require.Equal(t, 1, server.Calls())
        close(summarizer.gate)
        test.events.WaitFor(t, "idle", 1)
        require.Equal(t, 1, server.Calls())
-       require.NotContains(t, turnInputTexts(t, server.Call(0))[0], pending)
+       require.NotContains(t, turnInputTexts(t, server.Call(0))[0], viewPending)
 }
 
 func TestInterruptEndsTheTurn(t *testing.T) {
 }
 
 func TestInterruptEndsTheTurn(t *testing.T) {
@@ -308,16 +308,21 @@ func (r *TurnEventRecorder) Count(kind string) int {
 
 // Last returns the text of the last event of kind.
 func (r *TurnEventRecorder) Last(kind string) string {
 
 // Last returns the text of the last event of kind.
 func (r *TurnEventRecorder) Last(kind string) string {
+       return r.LastEvent(kind).Text
+}
+
+// LastEvent returns the last event of kind.
+func (r *TurnEventRecorder) LastEvent(kind string) Event {
        r.mutex.Lock()
        defer r.mutex.Unlock()
 
        for n := len(r.events) - 1; n >= 0; n-- {
                if r.events[n].Kind == kind {
        r.mutex.Lock()
        defer r.mutex.Unlock()
 
        for n := len(r.events) - 1; n >= 0; n-- {
                if r.events[n].Kind == kind {
-                       return r.events[n].Text
+                       return r.events[n]
                }
        }
 
                }
        }
 
-       return ""
+       return Event{}
 }
 
 func (r *TurnEventRecorder) Add(event Event) {
 }
 
 func (r *TurnEventRecorder) Add(event Event) {
@@ -386,7 +391,8 @@ func newTestTurnLoopWith(t *testing.T, server *ModelFake, summarizer Summarizer)
        }
 
        client := newModelClient(server.URL, ModelAPIKey(modelTestKey), agent.CacheKey(), test.usagePath)
        }
 
        client := newModelClient(server.URL, ModelAPIKey(modelTestKey), agent.CacheKey(), test.usagePath)
-       test.loop, err = newTurnLoop(agent, memory, client, clock.Now, test.events.Add)
+       whatsapp, _, _ := whatsappStartTest(t, t.TempDir(), clock)
+       test.loop, err = newTurnLoop(agent, memory, newTestSubagents(t), whatsapp, newTestSchedules(t, clock.Now), client, clock.Now, test.events.Add)
        require.NoError(t, err)
        ctx, cancel := context.WithCancel(t.Context())
        done := make(chan error)
        require.NoError(t, err)
        ctx, cancel := context.WithCancel(t.Context())
        done := make(chan error)