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)
| 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. |
| 815 | func 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. |
| 832 | func TestSlashModelRejectsUnknown(t *testing.T) { |
nothing calls this directly
no test coverage detected