X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/d9fddc0f506eb4ead7049f5638674b2b8773fcaa..80e348724041a694002fc38f57e8868b9b9a2be9:/tools_test.go?ds=sidebyside diff --git a/tools_test.go b/tools_test.go index ed58438..e1b19bb 100644 --- a/tools_test.go +++ b/tools_test.go @@ -93,6 +93,7 @@ func TestShellInterruptKillsTheCommandAndItsChildren(t *testing.T) { start := time.Now() output := box.shell(ctx, "echo started; sleep 30 & sleep 30") + require.Less(t, time.Since(start), 10*time.Second) require.Equal(t, "started\n\n[interrupted]", output) } @@ -222,6 +223,26 @@ type ToolRecordingLog struct { events []string } +// newTestToolbox returns a toolbox with log, an empty chat, and the working +// directory dir. +func newTestToolbox(t *testing.T, log ToolLog, dir string) *Toolbox { + t.Helper() + + memory, err := openMemory(t.Context(), t.TempDir(), newTestClock().Now, newFakeSummarizer(), discardLog()) + require.NoError(t, err) + + t.Cleanup(func() { + require.NoError(t, memory.Close()) + }) + + return &Toolbox{ + log: log, + chat: memory, + subagents: newTestSubagents(t), + workdir: dir, + } +} + func (r *ToolRecordingLog) Append(kind, text string) (Message, error) { r.mutex.Lock() defer r.mutex.Unlock() @@ -252,23 +273,3 @@ func (r *ToolRecordingLog) Events() []string { return append([]string(nil), r.events...) } - -// newTestToolbox returns a toolbox with log, an empty chat, and the working -// directory dir. -func newTestToolbox(t *testing.T, log ToolLog, dir string) *Toolbox { - t.Helper() - - memory, err := openMemory(t.Context(), t.TempDir(), newTestClock().Now, newFakeSummarizer(), discardLog()) - require.NoError(t, err) - - t.Cleanup(func() { - require.NoError(t, memory.Close()) - }) - - return &Toolbox{ - log: log, - chat: memory, - subagents: newTestSubagents(t), - workdir: dir, - } -}