MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestHandleStreamClosedEndsTurnWithNoPending

Function TestHandleStreamClosedEndsTurnWithNoPending

internal/tui/tui_test.go:1158–1180  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
installTurnContextMethod · 0.80
handleStreamClosedMethod · 0.80
activeMethod · 0.80

Tested by

no test coverage detected