MCPcopy Create free account
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 // Simulate three Done events. phase must be active or handleStream will
1679 // (correctly) drop events as stale post-cancel buffer: EventDone does
1680 // not move phase, so we seed streaming once and let each Done carry
1681 // through.
1682 m.phase = phaseStreaming
1683 for _, n := range []int{7, 13, 22} {
1684 out, _ := m.handleStream(llm.Event{Kind: llm.EventDone, Tokens: n})
1685 m = out.(Model)
1686 }
1687 if m.sessionTokens != 7+13+22 {
1688 t.Fatalf("session counter should sum all Done events: got %d, want %d",
1689 m.sessionTokens, 7+13+22)
1690 }
1691 if m.turnTokens != 7+13+22 {
1692 // Without a streamClosedMsg between events, turnTokens keeps summing
1693 // too, verifying the two counters are in lockstep before finalize.
1694 t.Fatalf("precondition: turn counter should equal session before finalize, got %d", m.turnTokens)
1695 }
1696}
1697
1698// TestSessionTokensSurviveFinalizeTurn: finalizeTurn clears turnTokens but

Callers

nothing calls this directly

Calls 2

newTestModelFunction · 0.85
finalizeTurnMethod · 0.80

Tested by

no test coverage detected