TestHandleStreamClosedEndsTurnWithNoPending: handleStreamClosed with an empty pending queue finalizes the turn, returns to idle, and returns no follow-up Cmd: nothing to enforce, no re-entry into chat.
(t *testing.T)
| 1156 | // pending queue finalizes the turn, returns to idle, and returns no follow-up |
| 1157 | // Cmd: nothing to enforce, no re-entry into chat. |
| 1158 | func TestHandleStreamClosedEndsTurnWithNoPending(t *testing.T) { |
| 1159 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 1160 | m.phase = phaseStreaming |
| 1161 | m.installTurnContext() // live turnCtx/cancel |
| 1162 | m.stream = make(chan llm.Event) |
| 1163 | before := len(m.history) |
| 1164 | |
| 1165 | out, cmd := m.handleStreamClosed() |
| 1166 | om := out.(Model) |
| 1167 | |
| 1168 | if cmd != nil { |
| 1169 | t.Fatal("a no-pending stream close must end the turn, not start another (nil Cmd)") |
| 1170 | } |
| 1171 | if om.phase.active() { |
| 1172 | t.Fatalf("turn must return to idle, phase=%v", om.phase) |
| 1173 | } |
| 1174 | if len(om.history) != before { |
| 1175 | t.Fatalf("turn end must not append any message, history grew by %d", len(om.history)-before) |
| 1176 | } |
| 1177 | if om.cancel != nil || om.turnCtx != nil { |
| 1178 | t.Fatal("endTurn must clear cancel/turnCtx") |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | // runTurn wires a model against handler, submits `text`, drains the command |
| 1183 | // chain, and returns the Model. token, when non-empty, is installed on both the |
nothing calls this directly
no test coverage detected