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

Function TestRunSlashPicksUpExternalConfigEdits

internal/tui/tui_test.go:939–968  ·  view source on GitHub ↗

TestRunSlashPicksUpExternalConfigEdits: runSlash re-reads .codehamr/config.yaml before dispatching, so a profile a user hand-added to the file mid-session shows up on the next /models without a restart.

(t *testing.T)

Source from the content-addressed store, hash-verified

937// .codehamr/config.yaml before dispatching, so a profile a user hand-added
938// to the file mid-session shows up on the next /models without a restart.
939func TestRunSlashPicksUpExternalConfigEdits(t *testing.T) {
940 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
941 // Hand-write a config adding "remote" alongside the seeded local,
942 // bypassing cfg.Save(): what a user would do in an external editor.
943 yaml := []byte(`active: local
944models:
945 local:
946 llm: local-model
947 url: ` + m.cfg.Models["local"].URL + `
948 key: ""
949 context_size: 131072
950 remote:
951 llm: cloud-model
952 url: http://remote:9000
953 key: sk-r
954 context_size: 200000
955`)
956 if err := os.WriteFile(filepath.Join(m.cfg.Dir, "config.yaml"), yaml, 0o600); err != nil {
957 t.Fatal(err)
958 }
959 if _, ok := m.cfg.Models["remote"]; ok {
960 t.Fatal("precondition: in-memory cfg must not know about 'remote' yet")
961 }
962 out, _ := m.runSlash("/models")
963 final := out.(Model)
964 if _, ok := final.cfg.Models["remote"]; !ok {
965 t.Fatalf("external edit not picked up - Models keys: %v",
966 final.cfg.ModelNames())
967 }
968}
969
970// TestRunSlashWarnsOnBrokenConfig: a typo in config.yaml must not lock the
971// user out of slash commands. The reload prints a one-line warning and

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
runSlashMethod · 0.80
ModelNamesMethod · 0.80

Tested by

no test coverage detected