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

Function TestArgPopoverReloadsCfgOnEntry

internal/tui/tui_test.go:872–900  ·  view source on GitHub ↗

TestArgPopoverReloadsCfgOnEntry: the arg popover builds its list from m.cfg.Models. Without the cmd→arg reload in refreshSuggest, the first "/models " sees stale in-memory cfg and misses a hand-added profile; reload-at-popover-open makes it visible on the first entry, not the second.

(t *testing.T)

Source from the content-addressed store, hash-verified

870// "/models " sees stale in-memory cfg and misses a hand-added profile;
871// reload-at-popover-open makes it visible on the first entry, not the second.
872func TestArgPopoverReloadsCfgOnEntry(t *testing.T) {
873 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
874 // Hand-write a "remote" profile straight to config.yaml, bypassing
875 // cfg.Save(): simulates an external editor.
876 yaml := []byte(`active: local
877models:
878 local:
879 llm: local-model
880 url: ` + m.cfg.Models["local"].URL + `
881 key: ""
882 context_size: 256000
883 remote:
884 llm: cloud-model
885 url: http://remote:9000
886 key: sk-r
887 context_size: 128000
888`)
889 if err := os.WriteFile(filepath.Join(m.cfg.Dir, "config.yaml"), yaml, 0o600); err != nil {
890 t.Fatal(err)
891 }
892 if _, ok := m.cfg.Models["remote"]; ok {
893 t.Fatal("precondition: in-memory cfg must not know about 'remote' yet")
894 }
895 mm := typeInto(m, "/models ")
896 names := suggestNames(mm)
897 if !slices.Contains(names, "remote") {
898 t.Fatalf("external 'remote' profile missing from arg popover on first /models entry, got %v", names)
899 }
900}
901
902// TestArgPopoverSkipsConfigReloadMidTurn: typing is allowed mid-turn, but the
903// cmd→arg popover transition must not reload config then: a reload can

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
typeIntoFunction · 0.85
suggestNamesFunction · 0.85

Tested by

no test coverage detected