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

Function TestSlashModelSwitchDropsStickyFallbackState

internal/tui/tui_test.go:791–808  ·  view source on GitHub ↗

TestSlashModelSwitchDropsStickyFallbackState: llm.Client's noReasoningEffort flag ("this server 400'd on tools+reasoning_effort, stop sending it") is correct for one Client but wrong across a profile switch to a different endpoint. rebuildClient swaps in a fresh Client; this asserts the pointer chan

(t *testing.T)

Source from the content-addressed store, hash-verified

789func TestSlashModelSwitchDropsStickyFallbackState(t *testing.T) {
790 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
791 m.cfg.Models["remote"] = &config.Profile{
792 LLM: "cloud-model", URL: "http://remote:9000", Key: "sk-r", ContextSize: 200000,
793 }
794 if err := m.cfg.Save(); err != nil {
795 t.Fatal(err)
796 }
797 before := m.cli
798 out, _ := m.runSlash("/models remote")
799 final := out.(Model)
800 if final.cli == before {
801 t.Fatal("rebuildClient must replace the *llm.Client pointer to drop sticky reasoning fallback state")
802 }
803 if final.cli.BaseURL != "http://remote:9000" || final.cli.Model != "cloud-model" || final.cli.Token != "sk-r" {
804 t.Fatalf("fresh client missing one of the new profile's fields: %+v", final.cli)
805 }
806}
807
808// TestSlashModelSwitchClearsStaleBudget: after a hamrpass turn leaves m.budget
809// set, switching to a profile that emits no X-Budget-* headers (local Ollama)
810// would keep rendering the old percentage forever; StatusSuffix only checks
811// .Set, not which profile produced it. rebuildClient must drop the cached

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
SaveMethod · 0.80
runSlashMethod · 0.80

Tested by

no test coverage detected