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

Function Test_ACPAgentIO_StreamingChunks

x/acpio/acpio_test.go:138–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func Test_ACPAgentIO_StreamingChunks(t *testing.T) {
139 collector := newChunkCollector()
140 agent := &testAgent{
141 onPrompt: func(ctx context.Context, conn *acp.AgentSideConnection, p acp.PromptRequest) (acp.PromptResponse, error) {
142 for _, text := range []string{"Hello", " ", "world!"} {
143 _ = conn.SessionUpdate(ctx, acp.SessionNotification{
144 SessionId: p.SessionId,
145 Update: acp.UpdateAgentMessageText(text),
146 })
147 }
148 return acp.PromptResponse{StopReason: acp.StopReasonEndTurn}, nil
149 },
150 }
151 agentIO := newTestPair(t, agent)
152 agentIO.SetOnChunk(collector.callback)
153
154 _, err := agentIO.Write([]byte("test"))
155 require.NoError(t, err)
156
157 // All three chunks should arrive (order may vary due to async notification handling).
158 chunks := collector.waitForN(t, 3)
159 assert.Len(t, chunks, 3)
160 assert.ElementsMatch(t, []string{"Hello", " ", "world!"}, chunks)
161}
162
163func Test_ACPAgentIO_StripsEscapeSequences(t *testing.T) {
164 received := make(chan string, 1)

Callers

nothing calls this directly

Calls 6

newChunkCollectorFunction · 0.85
newTestPairFunction · 0.85
SessionUpdateMethod · 0.80
waitForNMethod · 0.80
SetOnChunkMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected