MCPcopy Create free account
hub / github.com/coder/agentapi / Test_Send_AddsUserMessage

Function Test_Send_AddsUserMessage

x/acpio/acp_conversation_test.go:209–238  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func Test_Send_AddsUserMessage(t *testing.T) {
210 mClock := quartz.NewMock(t)
211 mock := newMockAgentIO()
212 // Set up blocking so we can inspect state mid-flight
213 started, done := mock.BlockWrite()
214
215 conv := acpio.NewACPConversation(context.Background(), mock, nil, nil, nil, mClock)
216 conv.Start(context.Background())
217
218 // Send blocks until completion, so run in a goroutine
219 errCh := make(chan error, 1)
220 go func() { errCh <- conv.Send(screentracker.MessagePartText{Content: "hello"}) }()
221
222 // Wait for the write to start
223 <-started
224
225 messages := conv.Messages()
226 require.Len(t, messages, 2) // user message + placeholder agent message
227
228 assert.Equal(t, screentracker.ConversationRoleUser, messages[0].Role)
229 assert.Equal(t, "hello", messages[0].Message)
230 assert.Equal(t, screentracker.ConversationRoleAgent, messages[1].Role)
231
232 // Signal a chunk so executePrompt's timer wait doesn't hang on the mock clock.
233 mock.SimulateChunks("hello response")
234
235 // Unblock the write to let Send complete
236 close(done)
237 require.NoError(t, <-errCh)
238}
239
240func Test_Send_RejectsEmptyMessage(t *testing.T) {
241 mClock := quartz.NewMock(t)

Callers

nothing calls this directly

Calls 7

StartMethod · 0.95
SendMethod · 0.95
MessagesMethod · 0.95
NewACPConversationFunction · 0.92
newMockAgentIOFunction · 0.85
BlockWriteMethod · 0.80
SimulateChunksMethod · 0.80

Tested by

no test coverage detected