newTestModel wires a model against a mock OpenAI SSE server so we can exercise submit → stream → done without the real stack. The server is torn down via t.Cleanup.
(t *testing.T, handler http.HandlerFunc)
| 28 | // exercise submit → stream → done without the real stack. The server is |
| 29 | // torn down via t.Cleanup. |
| 30 | func newTestModel(t *testing.T, handler http.HandlerFunc) Model { |
| 31 | t.Helper() |
| 32 | srv := httptest.NewServer(handler) |
| 33 | t.Cleanup(srv.Close) |
| 34 | |
| 35 | cfg, _, err := config.Bootstrap(t.TempDir()) |
| 36 | if err != nil { |
| 37 | t.Fatal(err) |
| 38 | } |
| 39 | cfg.ActiveProfile().URL = srv.URL |
| 40 | // Persist so the reload-on-slash path reads the mock URL back, not the |
| 41 | // seeded localhost default. |
| 42 | if err := cfg.Save(); err != nil { |
| 43 | t.Fatal(err) |
| 44 | } |
| 45 | client := llm.New(srv.URL, cfg.ActiveProfile().LLM, "") |
| 46 | m := New(cfg, client, t.TempDir(), "test") |
| 47 | // give it a size so view() doesn't panic |
| 48 | sized, _ := m.Update(tea.WindowSizeMsg{Width: 100, Height: 30}) |
| 49 | return sized.(Model) |
| 50 | } |
| 51 | |
| 52 | // TestSystemPromptIncludesWorkingDirAndInvestigateRule: the system prompt must |
| 53 | // (a) tell the model to investigate files itself rather than ask the user to |
no test coverage detected