TestFinalizeFoldsInFlightEstimate: a turn aborted mid-stream (Ctrl+C, error) has no EventDone to fold the current round's tokens into turnTokens; they sit in streamingEstimate. finalizeTurn must commit that estimate so the frozen avg counts what was generated up to the interrupt and the session tota
(t *testing.T)
| 1700 | t.Fatalf("precondition: turn counter should equal session before finalize, got %d", m.turnTokens) |
| 1701 | } |
| 1702 | } |
| 1703 | |
| 1704 | // TestSessionTokensSurviveFinalizeTurn: finalizeTurn clears turnTokens but |
| 1705 | // must NOT touch sessionTokens. turnStart must be set or finalizeTurn no-ops. |
| 1706 | func TestSessionTokensSurviveFinalizeTurn(t *testing.T) { |
| 1707 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 1708 | m.turnTokens = 50 |
| 1709 | m.turnStart = time.Now() |
| 1710 | m.sessionTokens = 123 |
| 1711 | m.finalizeTurn(outcomeDone) |
| 1712 | if m.turnTokens != 0 { |
| 1713 | t.Fatalf("turnTokens should be reset by finalizeTurn, got %d", m.turnTokens) |
| 1714 | } |
| 1715 | if m.sessionTokens != 123 { |
| 1716 | t.Fatalf("sessionTokens must not be touched by finalizeTurn, got %d", m.sessionTokens) |
| 1717 | } |
| 1718 | if m.lastOutcome != outcomeDone { |
| 1719 | t.Fatalf("finalizeTurn should freeze the outcome, got %v", m.lastOutcome) |
| 1720 | } |
| 1721 | } |
| 1722 | |
| 1723 | // TestFinalizeFoldsInFlightEstimate: a turn aborted mid-stream (Ctrl+C, error) |
| 1724 | // has no EventDone to fold the current round's tokens into turnTokens; they sit |
nothing calls this directly
no test coverage detected