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)
| 176 | // scanner would silently drop it anyway, so declining to write is consistent. |
| 177 | // Anything sane (a code paragraph, a stack trace) still survives. |
| 178 | func 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 | } |
nothing calls this directly
no test coverage detected