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

Function newTestModel

internal/tui/tui_test.go:30–50  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Calls 6

BootstrapFunction · 0.92
NewFunction · 0.92
ActiveProfileMethod · 0.80
SaveMethod · 0.80
NewFunction · 0.70
UpdateMethod · 0.45

Tested by

no test coverage detected