X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/e737005f89c7c663e1636830001730ad79396bdc..900ec0e7dad7a913190fcef9016e53495de9bdf8:/daemon_start_helper_test.go?ds=sidebyside diff --git a/daemon_start_helper_test.go b/daemon_start_helper_test.go index e7dea6c..8ed36e9 100644 --- a/daemon_start_helper_test.go +++ b/daemon_start_helper_test.go @@ -4,6 +4,7 @@ import ( "context" "path/filepath" "testing" + "time" "github.com/stretchr/testify/require" ) @@ -24,13 +25,22 @@ func daemonStartTestWithBot(t *testing.T, server *ModelFake, bot *TelegramBot) s func daemonStartTestWithWhatsApp(t *testing.T, server *ModelFake, bot *TelegramBot, whatsapp *WhatsApp) (string, *Memory) { t.Helper() + clock := newTestClock() + + return daemonStartTestWithSchedules(t, server, bot, whatsapp, newTestSchedules(t, clock.Now), clock.Now) +} + +// daemonStartTestWithSchedules is daemonStartTestWithWhatsApp with schedules, +// and with clock for the memory and the turns. +func daemonStartTestWithSchedules(t *testing.T, server *ModelFake, bot *TelegramBot, whatsapp *WhatsApp, schedules *Schedules, clock func() time.Time) (string, *Memory) { + t.Helper() + dir := t.TempDir() agent, err := openAgent(filepath.Join(dir, daemonAgentDirName)) require.NoError(t, err) agent.config.Workdir = t.TempDir() - clock := newTestClock() - memory, err := openMemory(t.Context(), agent.dir, clock.Now, newFakeSummarizer()) + memory, err := openMemory(t.Context(), agent.dir, clock, newFakeSummarizer(), discardLog()) require.NoError(t, err) socket := filepath.Join(dir, socketFileName) @@ -41,8 +51,8 @@ func daemonStartTestWithWhatsApp(t *testing.T, server *ModelFake, bot *TelegramB ctx, cancel := context.WithCancel(t.Context()) done := make(chan error) go func() { - 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) + done <- daemonServe(ctx, listener, bot, whatsapp, schedules, func(notify func(Event)) (*TurnLoop, error) { + return newTurnLoop(agent, memory, newTestSubagents(t), whatsapp, schedules, client, clock, discardLog(), notify) }) }()