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

Function Test_InitialPrompt_SentOnStart

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

Source from the content-addressed store, hash-verified

418}
419
420func Test_InitialPrompt_SentOnStart(t *testing.T) {
421 mClock := quartz.NewMock(t)
422 mock := newMockAgentIO()
423 // Set up blocking to synchronize with the initial prompt send
424 started, done := mock.BlockWrite()
425
426 initialPrompt := []screentracker.MessagePart{
427 screentracker.MessagePartText{Content: "initial prompt"},
428 }
429
430 conv := acpio.NewACPConversation(context.Background(), mock, nil, initialPrompt, nil, mClock)
431 conv.Start(context.Background())
432
433 // Wait for write to start (initial prompt is being sent via Start's goroutine)
434 <-started
435
436 // Should have user message from initial prompt
437 messages := conv.Messages()
438 require.GreaterOrEqual(t, len(messages), 1)
439 assert.Equal(t, screentracker.ConversationRoleUser, messages[0].Role)
440 assert.Equal(t, "initial prompt", messages[0].Message)
441
442 // Signal a chunk so executePrompt's timer wait doesn't hang on the mock clock.
443 mock.SimulateChunks("initial response")
444
445 // Unblock the write to let the test complete cleanly
446 close(done)
447}
448
449func Test_Messages_AreCopied(t *testing.T) {
450 mClock := quartz.NewMock(t)

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected