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

Function TestReadFileTruncatesOversizeContent

internal/tools/read_test.go:42–57  ·  view source on GitHub ↗

TestReadFileTruncatesOversizeContent: ReadFile obeys the same Truncate head+tail cap as every other tool. Oversize content must carry the marker so the model re-reads a slice rather than trusting a silently-clipped blob.

(t *testing.T)

Source from the content-addressed store, hash-verified

40// TestReadFileWindowsOversizeContent: a file past one window comes back as a
41// contiguous HEAD plus the exact offset to continue from - never Truncate's
42// head+tail with the middle dropped, which is the unrecoverable dead end
43// offset/limit exists to remove. The result must also stay under
44// ToolOutputCap*4 so Execute's Truncate can't re-fire on the window.
45func TestReadFileWindowsOversizeContent(t *testing.T) {
46 dir := t.TempDir()
47 path := filepath.Join(dir, "big.txt")
48 var b strings.Builder
49 for i := range 5000 {
50 fmt.Fprintf(&b, "line %d padding padding padding\n", i)
51 }
52 if err := os.WriteFile(path, []byte(b.String()), 0o644); err != nil {
53 t.Fatal(err)
54 }
55 got := ReadFile(path, 0, 0)
56 if !strings.Contains(got, "Continue with read_file offset=") {
57 t.Fatalf("windowed read should name the next offset, got %d bytes without it", len(got))
58 }
59 if strings.Contains(got, "───── truncated") {
60 t.Fatalf("windowed read must not fall through to head+tail truncation: %q", got[:200])

Callers

nothing calls this directly

Calls 1

ReadFileFunction · 0.85

Tested by

no test coverage detected