(t *testing.T)
| 207 | } |
| 208 | |
| 209 | func Test_Send_AddsUserMessage(t *testing.T) { |
| 210 | mClock := quartz.NewMock(t) |
| 211 | mock := newMockAgentIO() |
| 212 | // Set up blocking so we can inspect state mid-flight |
| 213 | started, done := mock.BlockWrite() |
| 214 | |
| 215 | conv := acpio.NewACPConversation(context.Background(), mock, nil, nil, nil, mClock) |
| 216 | conv.Start(context.Background()) |
| 217 | |
| 218 | // Send blocks until completion, so run in a goroutine |
| 219 | errCh := make(chan error, 1) |
| 220 | go func() { errCh <- conv.Send(screentracker.MessagePartText{Content: "hello"}) }() |
| 221 | |
| 222 | // Wait for the write to start |
| 223 | <-started |
| 224 | |
| 225 | messages := conv.Messages() |
| 226 | require.Len(t, messages, 2) // user message + placeholder agent message |
| 227 | |
| 228 | assert.Equal(t, screentracker.ConversationRoleUser, messages[0].Role) |
| 229 | assert.Equal(t, "hello", messages[0].Message) |
| 230 | assert.Equal(t, screentracker.ConversationRoleAgent, messages[1].Role) |
| 231 | |
| 232 | // Signal a chunk so executePrompt's timer wait doesn't hang on the mock clock. |
| 233 | mock.SimulateChunks("hello response") |
| 234 | |
| 235 | // Unblock the write to let Send complete |
| 236 | close(done) |
| 237 | require.NoError(t, <-errCh) |
| 238 | } |
| 239 | |
| 240 | func Test_Send_RejectsEmptyMessage(t *testing.T) { |
| 241 | mClock := quartz.NewMock(t) |
nothing calls this directly
no test coverage detected