(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func 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 | |
| 163 | func Test_ACPAgentIO_StripsEscapeSequences(t *testing.T) { |
| 164 | received := make(chan string, 1) |
nothing calls this directly
no test coverage detected