TestPromptHistoryCap: exceeding historyMaxEntries drops the oldest, not the newest, otherwise the file grows unbounded.
(t *testing.T)
| 36 | // TestPromptHistoryCap: exceeding historyMaxEntries drops the oldest, not the |
| 37 | // newest, otherwise the file grows unbounded. |
| 38 | func 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. |
nothing calls this directly
no test coverage detected