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

Function Test_Status_ChangesWhileProcessing

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

Source from the content-addressed store, hash-verified

304}
305
306func Test_Status_ChangesWhileProcessing(t *testing.T) {
307 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
308 defer cancel()
309
310 mClock := quartz.NewMock(t)
311 mock := newMockAgentIO()
312 emitter := newMockEmitter()
313 // Block the write so we can observe status changes
314 started, done := mock.BlockWrite()
315
316 conv := acpio.NewACPConversation(ctx, mock, nil, nil, emitter, mClock)
317 conv.Start(ctx)
318
319 // Send blocks, so run in a goroutine
320 errCh := make(chan error, 1)
321 go func() { errCh <- conv.Send(screentracker.MessagePartText{Content: "test"}) }()
322
323 // Wait for write to start
324 <-started
325
326 // Status should be changing while processing
327 assert.Equal(t, screentracker.ConversationStatusChanging, conv.Status())
328
329 // Signal a chunk so executePrompt's timer wait doesn't hang on the mock clock.
330 mock.SimulateChunks("test response")
331
332 // Unblock the write
333 close(done)
334
335 // Wait for Send to complete - status should then be stable.
336 require.NoError(t, <-errCh)
337 emitter.WaitForStatus(ctx, t, screentracker.ConversationStatusStable)
338}
339
340func Test_Text_ReturnsStreamingContent(t *testing.T) {
341 mClock := quartz.NewMock(t)

Callers

nothing calls this directly

Calls 9

StartMethod · 0.95
SendMethod · 0.95
StatusMethod · 0.95
NewACPConversationFunction · 0.92
newMockAgentIOFunction · 0.85
newMockEmitterFunction · 0.85
BlockWriteMethod · 0.80
SimulateChunksMethod · 0.80
WaitForStatusMethod · 0.80

Tested by

no test coverage detected