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

Function Test_Send_RejectsDuplicateSend

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

Source from the content-addressed store, hash-verified

276}
277
278func Test_Send_RejectsDuplicateSend(t *testing.T) {
279 mClock := quartz.NewMock(t)
280 mock := newMockAgentIO()
281 // Block the write so it doesn't complete immediately
282 started, done := mock.BlockWrite()
283
284 conv := acpio.NewACPConversation(context.Background(), mock, nil, nil, nil, mClock)
285 conv.Start(context.Background())
286
287 // First send blocks, so run in a goroutine
288 errCh := make(chan error, 1)
289 go func() { errCh <- conv.Send(screentracker.MessagePartText{Content: "first"}) }()
290
291 // Wait for the write to start (ensuring we're in "prompting" state)
292 <-started
293
294 // Second send while first is processing should fail
295 err := conv.Send(screentracker.MessagePartText{Content: "second"})
296 assert.ErrorIs(t, err, screentracker.ErrMessageValidationChanging)
297
298 // Signal a chunk so executePrompt's timer wait doesn't hang on the mock clock.
299 mock.SimulateChunks("first response")
300
301 // Unblock the write to let the test complete cleanly
302 close(done)
303 require.NoError(t, <-errCh)
304}
305
306func Test_Status_ChangesWhileProcessing(t *testing.T) {
307 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected