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

Function TestSlashModelSwitchClearsStaleBudget

internal/tui/tui_test.go:815–829  ·  view source on GitHub ↗

TestSlashModelSwitchClearsStaleBudget: after a hamrpass turn leaves m.budget set, switching to a profile that emits no X-Budget-* headers (local Ollama) would keep rendering the old percentage forever; StatusSuffix only checks .Set, not which profile produced it. rebuildClient must drop the cached s

(t *testing.T)

Source from the content-addressed store, hash-verified

813// .Set, not which profile produced it. rebuildClient must drop the cached
814// snapshot so the segment disappears until a new backend reports its own.
815func TestSlashModelSwitchClearsStaleBudget(t *testing.T) {
816 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
817 m.cfg.Models["local"] = &config.Profile{
818 LLM: "local-model", URL: "http://ollama:11434", Key: "", ContextSize: 32000,
819 }
820 m.budget = cloud.BudgetStatus{Set: true, Remaining: 0.88}
821 out, _ := m.runSlash("/models local")
822 final := out.(Model)
823 if final.budget.Set {
824 t.Fatalf("switching profiles must clear cached BudgetStatus, got %+v", final.budget)
825 }
826 if suf := final.budget.StatusSuffix(); suf != "" {
827 t.Fatalf("status suffix must be empty after switch, got %q", suf)
828 }
829}
830
831// TestSlashModelRejectsUnknown: unknown name is a quiet warn, not a switch.
832func TestSlashModelRejectsUnknown(t *testing.T) {

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
runSlashMethod · 0.80
StatusSuffixMethod · 0.80

Tested by

no test coverage detected