X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/2a276c273c21a1752d541bf87e074c5d1c27e30f..c781f79f3c8cb9a7577ee1574d196988da2719b3:/daemon_agent_test.go?ds=sidebyside diff --git a/daemon_agent_test.go b/daemon_agent_test.go index 7b1407b..5ee342a 100644 --- a/daemon_agent_test.go +++ b/daemon_agent_test.go @@ -3,6 +3,7 @@ package main import ( "context" "io" + "net/http" "os" "path/filepath" "strings" @@ -25,9 +26,19 @@ func TestDaemonOpensAndRunsTheRootAndTwoChildren(t *testing.T) { t.Cleanup(func() { require.NoError(t, agents.Close()) }) + require.Len(t, agents, 3) require.Equal(t, []string{"Garden", "Library"}, agents.ChildNames()) + server.reply = func(w http.ResponseWriter, call ModelFakeCall) { + text := "" + if call.body["prompt_cache_key"] == agents[0].agent.CacheKey() { + text = "The decision is recorded." + } + + modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem(text)}, 100, 0, 5)) + } + for _, agent := range agents { at := clock.Now().Add(time.Minute).Format(scheduleAtLayout) _, err = agent.schedules.Set("Record the decision for "+agent.agent.config.Name, &at, nil) @@ -56,7 +67,13 @@ func TestDaemonOpensAndRunsTheRootAndTwoChildren(t *testing.T) { require.Eventually(t, func() bool { for _, agent := range agents { - if agent.memory.Len() != 2 { + count := 1 + if agent == agents[0] { + count = 2 + } + + usage, err := os.ReadFile(filepath.Join(agent.agent.dir, "usage.jsonl")) + if err != nil || !strings.HasSuffix(string(usage), "\n") || agent.memory.Len() != count { return false } } @@ -237,6 +254,7 @@ func TestInvalidChildRelationshipsStopStartup(t *testing.T) { cause: "must have its own name and ID", }, } + for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { dir := t.TempDir()