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

Function TestPromptHistoryRoundTrip

internal/tui/history_store_test.go:14–34  ·  view source on GitHub ↗

TestPromptHistoryRoundTrip: values with newlines/quotes/unicode survive a disk round-trip in append order, the on-disk format must carry any byte the textarea can submit.

(t *testing.T)

Source from the content-addressed store, hash-verified

12// disk round-trip in append order, the on-disk format must carry any byte the
13// textarea can submit.
14func TestPromptHistoryRoundTrip(t *testing.T) {
15 dir := t.TempDir()
16 if got := loadPromptHistory(dir); len(got) != 0 {
17 t.Fatalf("fresh dir should have 0 entries, got %d", len(got))
18 }
19 want := []string{"first", "second\nwith newline", `third "quoted"`, "café 🐹"}
20 for _, v := range want {
21 if err := appendPromptHistory(dir, v); err != nil {
22 t.Fatal(err)
23 }
24 }
25 got := loadPromptHistory(dir)
26 if len(got) != len(want) {
27 t.Fatalf("got %d entries, want %d", len(got), len(want))
28 }
29 for i, w := range want {
30 if got[i].display != w {
31 t.Errorf("entry %d: got %q, want %q", i, got[i].display, w)
32 }
33 }
34}
35
36// TestPromptHistoryCap: exceeding historyMaxEntries drops the oldest, not the
37// newest, otherwise the file grows unbounded.

Callers

nothing calls this directly

Calls 2

loadPromptHistoryFunction · 0.85
appendPromptHistoryFunction · 0.85

Tested by

no test coverage detected