import (
"context"
"fmt"
- "log/slog"
"os"
"path/filepath"
"slices"
connections []context.Context
}
+// WhatsAppFakeSend is one send of the fake: the chat, the text, and the message
+// ID.
+type WhatsAppFakeSend struct {
+ to string
+ text string
+ id string
+}
+
+// WhatsAppRetryTest runs WhatsApp without a model or network client call. All
+// timers and channels belong to its synctest bubble, so backoff uses fake time.
+type WhatsAppRetryTest struct {
+ whatsapp *WhatsApp
+ fake *WhatsAppFake
+ logs *SyncBuffer
+ loop *TurnLoop
+ events *TurnEventRecorder
+ cancel context.CancelFunc
+ done chan error
+}
+
// ConnectContext keeps ctx and tells the test that the daemon connected.
func (f *WhatsAppFake) ConnectContext(ctx context.Context) error {
f.mutex.Lock()
return f
}
-// WhatsAppFakeSend is one send of the fake: the chat, the text, and the message
-// ID.
-type WhatsAppFakeSend struct {
- to string
- text string
- id string
-}
-
-// WhatsAppRetryTest runs WhatsApp without a model or network client call. All
-// timers and channels belong to its synctest bubble, so backoff uses fake time.
-type WhatsAppRetryTest struct {
- whatsapp *WhatsApp
- fake *WhatsAppFake
- logs *SyncBuffer
- loop *TurnLoop
- events *TurnEventRecorder
- cancel context.CancelFunc
- done chan error
-}
-
func (r *WhatsAppRetryTest) start(t *testing.T) {
t.Helper()
require.NoError(t, container.Close())
}
-// whatsappDiscardLog is a logger for a WhatsApp whose log a test does not read.
-func whatsappDiscardLog() *slog.Logger {
- return slog.New(slog.DiscardHandler)
-}
-
// whatsappTestMessage returns the event of the text message id of sender in
// chat at the time at. A sender with whatsappTestNumber is the user.
func whatsappTestMessage(chat, sender types.JID, id, text string, at time.Time) *events.Message {