X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/4b063ca25798c78cc03d1d07f67b02c94c95248d..02cdaff8be27f37f44db8892bb12554f2d702323:/daemon_test.go diff --git a/daemon_test.go b/daemon_test.go index 47fb9a5..d1f1bc5 100644 --- a/daemon_test.go +++ b/daemon_test.go @@ -17,14 +17,14 @@ import ( ) func TestClientsSeeTheTurnAsItHappens(t *testing.T) { - server := newFakeResponses(t) - server.reply = func(w http.ResponseWriter, call fakeCall) { + server := newModelFake(t) + server.reply = func(w http.ResponseWriter, call ModelFakeCall) { if call.number == 0 { - writeEvents(w, completedEvent([]any{functionCallItem("fc_1", "call_1", "shell", `{"command":"echo hi"}`)}, 100, 0, 5)) + modelWriteEvents(w, modelCompletedEvent([]any{modelFunctionCallItem("fc_1", "call_1", "shell", `{"command":"echo hi"}`)}, 100, 0, 5)) return } - writeEvents(w, completedEvent([]any{messageItem("It said hi.")}, 100, 0, 5)) + modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("It said hi.")}, 100, 0, 5)) } socket := startTestDaemon(t, server) @@ -46,14 +46,14 @@ func TestClientsSeeTheTurnAsItHappens(t *testing.T) { } func TestStopInterruptsTheTurn(t *testing.T) { - server := newFakeResponses(t) + server := newModelFake(t) arrived := make(chan struct{}) release := make(chan struct{}) t.Cleanup(func() { close(release) }) - server.reply = func(w http.ResponseWriter, call fakeCall) { + server.reply = func(w http.ResponseWriter, call ModelFakeCall) { close(arrived) <-release } @@ -239,14 +239,14 @@ func (b *syncBuffer) String() string { // startTestDaemon serves a new agent on a socket in a temporary directory and // returns the socket path. The commands of the agent run in a temporary // directory. -func startTestDaemon(t *testing.T, server *fakeResponses) string { +func startTestDaemon(t *testing.T, server *ModelFake) string { t.Helper() return startTestDaemonWithBot(t, server, nil) } // startTestDaemonWithBot is startTestDaemon with bot, which can be nil. -func startTestDaemonWithBot(t *testing.T, server *fakeResponses, bot *telegramBot) string { +func startTestDaemonWithBot(t *testing.T, server *ModelFake, bot *TelegramBot) string { t.Helper() dir := t.TempDir() @@ -262,7 +262,7 @@ func startTestDaemonWithBot(t *testing.T, server *fakeResponses, bot *telegramBo listener, err := listenSocket(socket) require.NoError(t, err) - client := newClient(server.URL, apiKey(testKey), agent.CacheKey(), filepath.Join(agent.dir, "usage.jsonl")) + client := newModelClient(server.URL, ModelAPIKey(modelTestKey), agent.CacheKey(), filepath.Join(agent.dir, "usage.jsonl")) ctx, cancel := context.WithCancel(t.Context()) done := make(chan error) go func() {