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

Function TestPromptHistoryRejectsHugeEntry

internal/tui/history_store_test.go:178–197  ·  view source on GitHub ↗

TestPromptHistoryRejectsHugeEntry: a multi-MiB paste isn't stored, the load scanner would silently drop it anyway, so declining to write is consistent. Anything sane (a code paragraph, a stack trace) still survives.

(t *testing.T)

Source from the content-addressed store, hash-verified

176// scanner would silently drop it anyway, so declining to write is consistent.
177// Anything sane (a code paragraph, a stack trace) still survives.
178func TestPromptHistoryRejectsHugeEntry(t *testing.T) {
179 dir := t.TempDir()
180 huge := strings.Repeat("x", historyMaxEntryBytes+1)
181 if err := appendPromptHistory(dir, huge); err != nil {
182 t.Fatal(err)
183 }
184 got := loadPromptHistory(dir)
185 if len(got) != 0 {
186 t.Fatalf("oversized entry should not be saved, got %d", len(got))
187 }
188 // At-the-cap entry still saves.
189 atCap := strings.Repeat("y", historyMaxEntryBytes)
190 if err := appendPromptHistory(dir, atCap); err != nil {
191 t.Fatal(err)
192 }
193 got = loadPromptHistory(dir)
194 if len(got) != 1 || got[0].display != atCap {
195 t.Fatalf("at-cap entry should round-trip, got %d entries", len(got))
196 }
197}

Callers

nothing calls this directly

Calls 2

appendPromptHistoryFunction · 0.85
loadPromptHistoryFunction · 0.85

Tested by

no test coverage detected