]> git.giacomolli.uk - onechat/blobdiff - whatsapp_test.go
Sync agent queue replacements before success
[onechat] / whatsapp_test.go
index 9da1537b58e69e97f53f8f58da0fd6510e049b0f..d200a91fbed394873356f46fb9b863e85b85f104 100644 (file)
@@ -2,7 +2,6 @@ package main
 
 import (
        "errors"
-       "log/slog"
        "os"
        "path/filepath"
        "strings"
@@ -91,7 +90,7 @@ func TestWhatsAppRetriesTheFirstConnectionWithCappedBackoff(t *testing.T) {
                time.Sleep(10 * time.Minute)
                synctest.Wait()
                require.Len(t, test.fake.Connections(), 11)
-               require.Equal(t, "<4>first connect failed, retrying: network unavailable\n<6>connected again after="+durationText(outage)+"\n", test.logs.String())
+               require.Equal(t, "<4>first connect failed, retrying: network unavailable\n<6>connected again after="+daemonLogDuration(outage)+"\n", test.logs.String())
        })
 }
 
@@ -357,7 +356,7 @@ func TestWhatsAppRefusesASessionThatOthersCanRead(t *testing.T) {
        whatsappTestSession(t, dir, true)
        require.NoError(t, os.Chmod(filepath.Join(dir, whatsappDirName, whatsappSessionFileName), 0o644))
 
-       _, err := openWhatsApp(t.Context(), dir, time.Now, whatsappDiscardLog(), whatsappNewClient)
+       _, err := openWhatsApp(t.Context(), dir, time.Now, discardLog(), whatsappNewClient)
        require.EqualError(t, err, "whatsapp/session.db holds the WhatsApp session, so its mode must be 0600")
 }
 
@@ -602,7 +601,7 @@ func TestWhatsAppLogoutFromThePhone(t *testing.T) {
        notice := "WhatsApp was unlinked from the phone. Run /whatsapp pair PHONE to link it again."
        client.WaitFor(t, notice)
        telegramWaitForSent(t, telegram, notice)
-       require.Equal(t, "<3>logged out by the phone, run /whatsapp pair PHONE\n", logs.String())
+       require.Equal(t, "<3>logged out by the phone\n", logs.String())
        require.NoFileExists(t, filepath.Join(dir, whatsappDirName, whatsappSessionFileName))
        require.Equal(t, "WhatsApp is not linked. Run /whatsapp pair PHONE to link it.", whatsapp.Status())
        require.Equal(t, []string{"WhatsApp was unlinked from the phone."}, whatsappTestLogTexts(t, memory))
@@ -758,8 +757,3 @@ func TestSubagentHasNoWhatsAppTools(t *testing.T) {
        require.Equal(t, `error: unknown tool "whatsapp_find"`, box.run(t.Context(), "whatsapp_find", `{"name":"ana"}`))
        require.Equal(t, `error: unknown tool "whatsapp_send"`, box.run(t.Context(), "whatsapp_send", `{"id":"a","chat":"15550002222@s.whatsapp.net","text":"hi"}`))
 }
-
-// whatsappDiscardLog is a logger for a WhatsApp whose log a test does not read.
-func whatsappDiscardLog() *slog.Logger {
-       return slog.New(slog.DiscardHandler)
-}