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

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
typeIntoFunction · 0.85
suggestNamesFunction · 0.85

Tested by

no test coverage detected