TestQueueAutoFireUnitFromStreamClosed: a clean, trivial finish with a prompt queued must submit it from handleStreamClosed: phase back to thinking, a chat Cmd returned, the queued user message appended, and the slot cleared.
(t *testing.T)
| 341 | |
| 342 | // TestQueueAutoFireUnitFromStreamClosed: a clean, trivial finish with a prompt |
| 343 | // queued must submit it from handleStreamClosed: phase back to thinking, a chat |
| 344 | // Cmd returned, the queued user message appended, and the slot cleared. |
| 345 | func TestQueueAutoFireUnitFromStreamClosed(t *testing.T) { |
| 346 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 347 | m.installTurnContext() |
| 348 | m.phase = phaseStreaming |
| 349 | m.stream = make(chan llm.Event) // non-nil so handleStreamClosed proceeds |
| 350 | m.history = []chmctx.Message{ |
| 351 | {Role: chmctx.RoleUser, Content: "first"}, |
| 352 | {Role: chmctx.RoleAssistant, Content: "done"}, |
| 353 | } |
| 354 | m.queued = &queuedPrompt{send: "next task", echo: "next task"} |
| 355 | |
| 356 | out, cmd := m.handleStreamClosed() |
| 357 | om := out.(Model) |
| 358 | |
| 359 | if cmd == nil { |
| 360 | t.Fatal("a queued prompt must start the next turn (non-nil Cmd)") |
| 361 | } |
| 362 | if om.phase != phaseThinking { |
| 363 | t.Fatalf("auto-fire must begin a new turn (thinking), got %v", om.phase) |
| 364 | } |
| 365 | if om.queued != nil { |
| 366 | t.Fatalf("slot must clear on auto-fire, got %+v", om.queued) |
| 367 | } |
| 368 | last := om.history[len(om.history)-1] |
| 369 | if last.Role != chmctx.RoleUser || last.Content != "next task" { |
| 370 | t.Fatalf("auto-fire must append the queued user message, got %+v", last) |
| 371 | } |
| 372 | } |
nothing calls this directly
no test coverage detected