X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/6e3e9c5c10f3d35bae7e9846334974a09418aef7..a6a82d96b4906e9e1f09f45f69f48124f11ae1bb:/daemon_start_helper_test.go?ds=sidebyside diff --git a/daemon_start_helper_test.go b/daemon_start_helper_test.go index 1952e77..baa527b 100644 --- a/daemon_start_helper_test.go +++ b/daemon_start_helper_test.go @@ -9,9 +9,21 @@ import ( ) // 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) @@ -29,8 +41,8 @@ func daemonStartTestWithBot(t *testing.T, server *ModelFake, bot *TelegramBot) s 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, newTestSubagents(t), client, clock.Now, notify) + done <- daemonServe(ctx, listener, bot, whatsapp, func(notify func(Event)) (*TurnLoop, error) { + return newTurnLoop(agent, memory, newTestSubagents(t), whatsapp, client, clock.Now, notify) }) }() @@ -40,5 +52,5 @@ func daemonStartTestWithBot(t *testing.T, server *ModelFake, bot *TelegramBot) s require.NoError(t, memory.Close()) }) - return socket + return socket, memory }