]> git.giacomolli.uk - onechat/blobdiff - turn_test.go
Order functions by their first use
[onechat] / turn_test.go
index 733c9a935d61c7f8ae9a7caca1012e6995ffd5a6..27151a9af9d6bafb1191c5da589f6c8cfb2a43ea 100644 (file)
@@ -57,6 +57,7 @@ func TestTurnRunsToolsUntilTheFinalAnswer(t *testing.T) {
                "echo: hi\n",
                "reply: It said hi.",
        }, test.Log(t))
+
        require.Equal(t, []string{"user", "busy", "tool", "echo", "reply", "idle"}, test.events.Kinds())
 
        var turns []string
@@ -369,6 +370,13 @@ func (r *TurnEventRecorder) Last(kind string) string {
        return r.LastEvent(kind).Text
 }
 
+func (r *TurnEventRecorder) Add(event Event) {
+       r.mutex.Lock()
+       defer r.mutex.Unlock()
+
+       r.events = append(r.events, event)
+}
+
 // LastEvent returns the last event of kind.
 func (r *TurnEventRecorder) LastEvent(kind string) Event {
        r.mutex.Lock()
@@ -383,11 +391,13 @@ func (r *TurnEventRecorder) LastEvent(kind string) Event {
        return Event{}
 }
 
-func (r *TurnEventRecorder) Add(event Event) {
-       r.mutex.Lock()
-       defer r.mutex.Unlock()
-
-       r.events = append(r.events, event)
+func modelReasoningItem(id, encrypted string) map[string]any {
+       return map[string]any{
+               "type":              "reasoning",
+               "id":                id,
+               "encrypted_content": encrypted,
+               "summary":           []any{},
+       }
 }
 
 // turnInputTexts returns the text of each user message of the input of call.
@@ -423,12 +433,3 @@ func turnInputTexts(t *testing.T, call ModelFakeCall) []string {
 
        return texts
 }
-
-func modelReasoningItem(id, encrypted string) map[string]any {
-       return map[string]any{
-               "type":              "reasoning",
-               "id":                id,
-               "encrypted_content": encrypted,
-               "summary":           []any{},
-       }
-}