MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestPromptHistoryCap

Function TestPromptHistoryCap

internal/tui/history_store_test.go:38–54  ·  view source on GitHub ↗

TestPromptHistoryCap: exceeding historyMaxEntries drops the oldest, not the newest, otherwise the file grows unbounded.

(t *testing.T)

Source from the content-addressed store, hash-verified

36// TestPromptHistoryCap: exceeding historyMaxEntries drops the oldest, not the
37// newest, otherwise the file grows unbounded.
38func TestPromptHistoryCap(t *testing.T) {
39 dir := t.TempDir()
40 for i := 0; i < historyMaxEntries+50; i++ {
41 if err := appendPromptHistory(dir, "p"+strings.Repeat("x", i%3)); err != nil {
42 t.Fatal(err)
43 }
44 }
45 got := loadPromptHistory(dir)
46 if len(got) != historyMaxEntries {
47 t.Fatalf("cap not enforced: %d entries on disk, want %d", len(got), historyMaxEntries)
48 }
49 // Head entry = the 50th submit (oldest 50 dropped): trim is from the head.
50 wantHead := "p" + strings.Repeat("x", 50%3)
51 if got[0].display != wantHead {
52 t.Errorf("trim direction wrong: head=%q want %q", got[0].display, wantHead)
53 }
54}
55
56// TestPromptHistorySkipEmpty: empty submits never reach the file, so a stray ↵
57// can't pollute recall with blanks.

Callers

nothing calls this directly

Calls 2

appendPromptHistoryFunction · 0.85
loadPromptHistoryFunction · 0.85

Tested by

no test coverage detected