]> git.giacomolli.uk - onechat/blobdiff - daemon_test.go
Use both logs for WhatsApp import cutoffs
[onechat] / daemon_test.go
index 6a8cd3e5337b07c14e17a7d3125668f2704e7e54..6a4d98c5a040456d0baf8e06fb4307542bcbb56a 100644 (file)
@@ -16,6 +16,7 @@ func TestClientsSeeTheTurnAsItHappens(t *testing.T) {
        server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
                if call.number == 0 {
                        modelWriteEvents(w, modelCompletedEvent([]any{modelFunctionCallItem("fc_1", "call_1", "shell", `{"command":"echo hi"}`)}, 100, 0, 5))
        server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
                if call.number == 0 {
                        modelWriteEvents(w, modelCompletedEvent([]any{modelFunctionCallItem("fc_1", "call_1", "shell", `{"command":"echo hi"}`)}, 100, 0, 5))
+
                        return
                }
 
                        return
                }
 
@@ -29,6 +30,7 @@ func TestClientsSeeTheTurnAsItHappens(t *testing.T) {
        second.WaitFor(t, "[connected to OneChat]")
 
        first.Type("Run echo hi.")
        second.WaitFor(t, "[connected to OneChat]")
 
        first.Type("Run echo hi.")
+
        for _, client := range []*TerminalTestClient{first, second} {
                client.WaitFor(t, "[done]")
                require.Equal(t, "[connected to OneChat]\n[working]\n[tool] shell {\"command\":\"echo hi\"}\n[result] hi\nIt said hi.\n[done]\n", client.Output())
        for _, client := range []*TerminalTestClient{first, second} {
                client.WaitFor(t, "[done]")
                require.Equal(t, "[connected to OneChat]\n[working]\n[tool] shell {\"command\":\"echo hi\"}\n[result] hi\nIt said hi.\n[done]\n", client.Output())
@@ -107,12 +109,12 @@ func TestDaemonLogHasATimeStampOnlyOutsideTheJournal(t *testing.T) {
                {
                        name:    "the journal adds the time itself",
                        journal: "8:12345",
                {
                        name:    "the journal adds the time itself",
                        journal: "8:12345",
-                       line:    `^onechat: the agent is ready\n$`,
+                       line:    `^<6>onechat: the agent is ready\n$`,
                },
                {
                        name:    "a terminal gets the time in the line",
                        journal: "",
                },
                {
                        name:    "a terminal gets the time in the line",
                        journal: "",
-                       line:    `^onechat: \d{4}/\d\d/\d\d \d\d:\d\d:\d\d the agent is ready\n$`,
+                       line:    `^\d{4}/\d\d/\d\d \d\d:\d\d:\d\d INFO onechat: the agent is ready\n$`,
                },
        }
 
                },
        }
 
@@ -121,7 +123,8 @@ func TestDaemonLogHasATimeStampOnlyOutsideTheJournal(t *testing.T) {
                        t.Setenv("JOURNAL_STREAM", tc.journal)
 
                        var out strings.Builder
                        t.Setenv("JOURNAL_STREAM", tc.journal)
 
                        var out strings.Builder
-                       daemonLogger(&out, "onechat: ").Print("the agent is ready")
+
+                       daemonLogger(&out, "onechat: ").Info("the agent is ready")
                        require.Regexp(t, tc.line, out.String())
                })
        }
                        require.Regexp(t, tc.line, out.String())
                })
        }