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

Function Test_ACPAgentIO_WriteAndReadScreen

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

Source from the content-addressed store, hash-verified

113}
114
115func Test_ACPAgentIO_WriteAndReadScreen(t *testing.T) {
116 collector := newChunkCollector()
117 agent := &testAgent{
118 onPrompt: func(ctx context.Context, conn *acp.AgentSideConnection, p acp.PromptRequest) (acp.PromptResponse, error) {
119 _ = conn.SessionUpdate(ctx, acp.SessionNotification{
120 SessionId: p.SessionId,
121 Update: acp.UpdateAgentMessageText("Hello from agent!"),
122 })
123 return acp.PromptResponse{StopReason: acp.StopReasonEndTurn}, nil
124 },
125 }
126 agentIO := newTestPair(t, agent)
127 agentIO.SetOnChunk(collector.callback)
128
129 n, err := agentIO.Write([]byte("test prompt"))
130 require.NoError(t, err)
131 assert.Equal(t, len("test prompt"), n)
132
133 // SessionUpdate notifications are async — wait for the chunk to arrive.
134 collector.waitForN(t, 1)
135 assert.Equal(t, "Hello from agent!", agentIO.ReadScreen())
136}
137
138func Test_ACPAgentIO_StreamingChunks(t *testing.T) {
139 collector := newChunkCollector()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected