TestRunSlashWarnsOnBrokenConfig: a typo in config.yaml must not lock the user out of slash commands. The reload prints a one-line warning and keeps the previous in-memory cfg, so /models (and further editing) keep working with last-known-good state.
(t *testing.T)
| 972 | // keeps the previous in-memory cfg, so /models (and further editing) keep |
| 973 | // working with last-known-good state. |
| 974 | func TestRunSlashWarnsOnBrokenConfig(t *testing.T) { |
| 975 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 976 | prevActive := m.cfg.Active |
| 977 | prevModels := len(m.cfg.Models) |
| 978 | if err := os.WriteFile(filepath.Join(m.cfg.Dir, "config.yaml"), |
| 979 | []byte("active: [unterminated\nmodels: {{"), 0o600); err != nil { |
| 980 | t.Fatal(err) |
| 981 | } |
| 982 | out, _ := m.runSlash("/models") |
| 983 | final := out.(Model) |
| 984 | scroll := stripANSI(final.scroll.String()) |
| 985 | if !strings.Contains(scroll, "config.yaml") { |
| 986 | t.Fatalf("scrollback should warn about broken config.yaml:\n%s", scroll) |
| 987 | } |
| 988 | if final.cfg.Active != prevActive { |
| 989 | t.Fatalf("broken-config reload must preserve previous Active, got %q want %q", |
| 990 | final.cfg.Active, prevActive) |
| 991 | } |
| 992 | if len(final.cfg.Models) != prevModels { |
| 993 | t.Fatalf("broken-config reload must preserve previous Models, got %d want %d", |
| 994 | len(final.cfg.Models), prevModels) |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | // TestSlashClearSurvivesBrokenConfig: with config.yaml unparseable, /clear must |
| 999 | // still wipe history. The reload warning gets wiped with the rest of scrollback |
nothing calls this directly
no test coverage detected