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

Function TestProbeBudgetSnapshotIgnoredForStaleProfile

internal/tui/tui_test.go:1323–1337  ·  view source on GitHub ↗

TestProbeBudgetSnapshotIgnoredForStaleProfile: a budget snapshot from a probe that lost the /models race (msg.profile != m.cfg.Active) must not overwrite the live profile's m.budget. Mirrors the stale-probe guard the connected flag already has.

(t *testing.T)

Source from the content-addressed store, hash-verified

1321
1322// TestProbeBudgetExhaustedUpdatesStatusBar: a 402 probe carries a
1323// BudgetStatus{Set:true, Remaining:0} snapshot. handleProbe must apply it to
1324// m.budget so the bar paints "0% pass" now, not after the first chat call 402s.
1325func TestProbeBudgetExhaustedUpdatesStatusBar(t *testing.T) {
1326 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
1327 m.cfg.Active = "hamrpass"
1328 out, _ := m.handleProbe(probeMsg{
1329 profile: "hamrpass",
1330 cli: m.cli,
1331 budget: cloud.BudgetStatus{Set: true, Remaining: 0},
1332 silent: true,
1333 err: cloud.ErrBudgetExhausted,
1334 })
1335 final := out.(Model)
1336 if !final.budget.Set {
1337 t.Fatal("402 probe must apply the depleted-budget snapshot to m.budget")
1338 }
1339 if final.budget.Remaining != 0 {
1340 t.Fatalf("budget.Remaining = %v, want 0", final.budget.Remaining)

Callers

nothing calls this directly

Calls 2

newTestModelFunction · 0.85
handleProbeMethod · 0.80

Tested by

no test coverage detected