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

Function TestHumanRateFormat

internal/tui/tui_test.go:1630–1651  ·  view source on GitHub ↗

TestHumanRateFormat: throughput as `N tok/s`. Degenerate inputs (zero tokens or zero elapsed) collapse to "" so the banner omits the segment. Sub-10 tok/s keeps one decimal: reasoning models hover near 1 tok/s where it's the signal.

(t *testing.T)

Source from the content-addressed store, hash-verified

1628 }
1629 if nudges != 1 {
1630 t.Fatalf("expected exactly one RoleSystem nudge after %d same target failures, got %d:\n%+v",
1631 maxToolFailStreak, nudges, final.history)
1632 }
1633 if !strings.Contains(last.Content, fmt.Sprintf("last %d tool calls", maxToolFailStreak)) {
1634 t.Fatalf("nudge should name the streak count: %q", last.Content)
1635 }
1636 // Streak resets after firing so it can't double fire on the next failure.
1637 if final.failStreak != 0 || final.failKey != "" {
1638 t.Fatalf("nudge must reset failKey/failStreak, got key=%q streak=%d", final.failKey, final.failStreak)
1639 }
1640}
1641
1642// recordAndNudge replays Update's toolResultMsg "queue drained" branch: record
1643// the outcome, then consider the failure nudge. Lets the streak tests exercise
1644// the real recordToolOutcome + maybeFailureNudge without a live SSE turn.
1645func (m Model) recordAndNudge(result chmctx.Message) (tea.Model, tea.Cmd) {
1646 m.history = append(m.history, result)
1647 m.recordToolOutcome(result.ToolName, result.Content)
1648 m.maybeFailureNudge()
1649 return m, nil
1650}
1651
1652// TestRepeatedFailureNudgeSuccessResetsStreak: a single success in the middle
1653// of a run of failures resets the streak, so the nudge never fires.
1654func TestRepeatedFailureNudgeSuccessResetsStreak(t *testing.T) {

Callers

nothing calls this directly

Calls 1

humanRateFunction · 0.85

Tested by

no test coverage detected