)
// daemonStartTestWithBot is daemonStartTest with bot, which can be nil.
+// WhatsApp is not linked.
func daemonStartTestWithBot(t *testing.T, server *ModelFake, bot *TelegramBot) string {
t.Helper()
+ whatsapp, _, _ := whatsappStartTest(t, t.TempDir(), newTestClock())
+ socket, _ := daemonStartTestWithWhatsApp(t, server, bot, whatsapp)
+
+ return socket
+}
+
+// daemonStartTestWithWhatsApp is daemonStartTestWithBot with whatsapp. It also
+// returns the memory of the agent.
+func daemonStartTestWithWhatsApp(t *testing.T, server *ModelFake, bot *TelegramBot, whatsapp *WhatsApp) (string, *Memory) {
+ t.Helper()
+
dir := t.TempDir()
agent, err := openAgent(filepath.Join(dir, daemonAgentDirName))
require.NoError(t, err)
ctx, cancel := context.WithCancel(t.Context())
done := make(chan error)
go func() {
- done <- daemonServe(ctx, listener, bot, func(notify func(Event)) (*TurnLoop, error) {
- return newTurnLoop(agent, memory, client, clock.Now, notify)
+ done <- daemonServe(ctx, listener, bot, whatsapp, func(notify func(Event)) (*TurnLoop, error) {
+ return newTurnLoop(agent, memory, newTestSubagents(t), whatsapp, newTestSchedules(t, clock.Now), client, clock.Now, notify)
})
}()
require.NoError(t, memory.Close())
})
- return socket
+ return socket, memory
}