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

Function TestPromptHistoryCorruptLineSkipped

internal/tui/history_store_test.go:92–103  ·  view source on GitHub ↗

TestPromptHistoryCorruptLineSkipped: a malformed line (users may hand-edit the file) must not poison the valid entries around it.

(t *testing.T)

Source from the content-addressed store, hash-verified

90// TestPromptHistoryCorruptLineSkipped: a malformed line (users may hand-edit
91// the file) must not poison the valid entries around it.
92func TestPromptHistoryCorruptLineSkipped(t *testing.T) {
93 dir := t.TempDir()
94 path := filepath.Join(dir, historyFileName)
95 body := "not a quoted line\n" + `"valid"` + "\n"
96 if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
97 t.Fatal(err)
98 }
99 got := loadPromptHistory(dir)
100 if len(got) != 1 || got[0].display != "valid" {
101 t.Errorf("expected 1 valid entry, got %+v", got)
102 }
103}
104
105// TestPromptHistoryConcurrentAppendsKeepBoth guards the load-then-rewrite race:
106// two instances sharing a project dir would each read N entries and overwrite

Callers

nothing calls this directly

Calls 1

loadPromptHistoryFunction · 0.85

Tested by

no test coverage detected