]> git.giacomolli.uk - onechat/blobdiff - whatsapp_test.go
Test the commit message wrapping boundaries
[onechat] / whatsapp_test.go
index 9da1537b58e69e97f53f8f58da0fd6510e049b0f..6475805f0aac2ae17674d98343f032cf51c090b1 100644 (file)
@@ -2,7 +2,6 @@ package main
 
 import (
        "errors"
 
 import (
        "errors"
-       "log/slog"
        "os"
        "path/filepath"
        "strings"
        "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)
                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))
 
        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")
 }
 
        require.EqualError(t, err, "whatsapp/session.db holds the WhatsApp session, so its mode must be 0600")
 }
 
@@ -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"}`))
 }
        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)
-}