X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/7b6d0a81e0f3c8e33b1b76d5ecbc5bdb25a87249..0018014ab36f3de61a4b8a5515009dab803d6c38:/turn_test.go diff --git a/turn_test.go b/turn_test.go index b89a0ec..b0417cf 100644 --- a/turn_test.go +++ b/turn_test.go @@ -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 { + 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 { - return r.events[n].Text + return r.events[n] } } - return "" + return Event{} } func (r *TurnEventRecorder) Add(event Event) { @@ -386,7 +391,7 @@ func newTestTurnLoopWith(t *testing.T, server *ModelFake, summarizer Summarizer) } client := newModelClient(server.URL, ModelAPIKey(modelTestKey), agent.CacheKey(), test.usagePath) - test.loop, err = newTurnLoop(agent, memory, client, clock.Now, test.events.Add) + test.loop, err = newTurnLoop(agent, memory, newTestSubagents(t), client, clock.Now, test.events.Add) require.NoError(t, err) ctx, cancel := context.WithCancel(t.Context()) done := make(chan error)