MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestSessionTokensSurviveFinalizeTurn

Function TestSessionTokensSurviveFinalizeTurn

internal/tui/tui_test.go:1680–1695  ·  view source on GitHub ↗

TestSessionTokensSurviveFinalizeTurn: finalizeTurn clears turnTokens but must NOT touch sessionTokens. turnStart must be set or finalizeTurn no-ops.

(t *testing.T)

Source from the content-addressed store, hash-verified

1678// TestSessionTokensAccumulateAcrossTurns: the session counter is separate
1679// from the per-turn counter. finalizeTurn resets turnTokens; sessionTokens
1680// keeps growing for the rest of the session.
1681func TestSessionTokensAccumulateAcrossTurns(t *testing.T) {
1682 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
1683 // Simulate three Done events. phase must be active or handleStream will
1684 // (correctly) drop events as stale post-cancel buffer: EventDone does
1685 // not move phase, so we seed streaming once and let each Done carry
1686 // through.
1687 m.phase = phaseStreaming
1688 for _, n := range []int{7, 13, 22} {
1689 out, _ := m.handleStream(llm.Event{Kind: llm.EventDone, Tokens: n})
1690 m = out.(Model)
1691 }
1692 if m.sessionTokens != 7+13+22 {
1693 t.Fatalf("session counter should sum all Done events: got %d, want %d",
1694 m.sessionTokens, 7+13+22)
1695 }
1696 if m.turnTokens != 7+13+22 {
1697 // Without a streamClosedMsg between events, turnTokens keeps summing
1698 // too, verifying the two counters are in lockstep before finalize.

Callers

nothing calls this directly

Calls 2

newTestModelFunction · 0.85
finalizeTurnMethod · 0.80

Tested by

no test coverage detected