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)
| 12 | // disk round-trip in append order, the on-disk format must carry any byte the |
| 13 | // textarea can submit. |
| 14 | func 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. |
nothing calls this directly
no test coverage detected