X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/a6a82d96b4906e9e1f09f45f69f48124f11ae1bb..36229ef68a30c5a117599037d79fa1fc708fbfef:/whatsapp_inbox_test.go?ds=sidebyside diff --git a/whatsapp_inbox_test.go b/whatsapp_inbox_test.go index 7e9d3a3..c3937df 100644 --- a/whatsapp_inbox_test.go +++ b/whatsapp_inbox_test.go @@ -17,7 +17,7 @@ func TestWhatsAppPrivateBatchStartsATurnWithAnEmptyReply(t *testing.T) { require.NoError(t, whatsapp.device.Contacts.PutContactName(t.Context(), whatsappTestAna, "Ana", "Ana Souza")) server := newModelFake(t) - server.reply = func(w http.ResponseWriter, call ModelFakeCall) { + server.reply = func(w http.ResponseWriter, _ ModelFakeCall) { modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("")}, 100, 0, 5)) } @@ -31,6 +31,7 @@ func TestWhatsAppPrivateBatchStartsATurnWithAnEmptyReply(t *testing.T) { // The catch-up holds the batch open until its end, so the two messages // form one batch also on a slow machine. require.True(t, fake.Emit(&events.Connected{})) + at := time.Date(2026, 1, 1, 12, 0, 0, 0, time.UTC) require.True(t, fake.Emit(whatsappTestMessage(whatsappTestAna, whatsappTestAna, "m1", "Are you at home?", at))) require.True(t, fake.Emit(whatsappTestMessage(whatsappTestAna, whatsappTestOwn, "m2", "Yes", at))) @@ -56,7 +57,7 @@ func TestWhatsAppGroupTurns(t *testing.T) { }{ { name: "plain", - message: func(event *events.Message) { + message: func(_ *events.Message) { }, line: "12:00 Bruno Lima: Who brings the cake?", }, @@ -118,6 +119,7 @@ func TestWhatsAppGroupTurns(t *testing.T) { text := "[WhatsApp] Family, group 120363000000000001@g.us, Thursday 2026-01-01\n" + tc.line if tc.turn { text += "\n" + whatsappBatchEmptyReply + client.WaitFor(t, "[done]") require.Equal(t, 1, server.Calls()) } else { @@ -212,6 +214,7 @@ func TestWhatsAppCatchupGivesOneTurn(t *testing.T) { <-fake.connects require.True(t, fake.Emit(&events.Connected{})) + at := time.Date(2026, 1, 1, 8, 0, 0, 0, time.UTC) for index, event := range []*events.Message{ whatsappTestMessage(whatsappTestAna, whatsappTestAna, "m1", "Good morning", at), @@ -235,6 +238,7 @@ func TestWhatsAppCatchupGivesOneTurn(t *testing.T) { time.Sleep(100 * time.Millisecond) require.Equal(t, 1, server.Calls()) + for _, text := range []string{"Good morning", "Call me", "Are you there?"} { require.Contains(t, string(server.Call(0).raw), text) } @@ -257,6 +261,7 @@ func TestWhatsAppCatchupEndsAfterItsLimit(t *testing.T) { func TestWhatsAppStateOfTheStateFileWaitForTheCatchup(t *testing.T) { dir := t.TempDir() whatsappTestSession(t, dir, true) + before, _, _ := whatsappStartTest(t, dir, newTestClock()) _, err := before.state.Add(whatsappTestChat, WhatsAppMessage{ ID: "m1",