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// head+tail cap as every other tool. Oversize content must carry the marker so
41// the model re-reads a slice rather than trusting a silently-clipped blob.
42func TestReadFileTruncatesOversizeContent(t *testing.T) {
43 dir := t.TempDir()
44 path := filepath.Join(dir, "big.txt")
45 // Over ToolOutputCap*4 bytes so Truncate fires.
46 big := strings.Repeat("x", chmctx.ToolOutputCap*4+1000)
47 if err := os.WriteFile(path, []byte(big), 0o644); err != nil {
48 t.Fatal(err)
49 }
50 got := ReadFile(path)
51 if !strings.Contains(got, "───── truncated") {
52 t.Fatalf("oversize read should carry the truncation marker, got %d bytes without it", len(got))
53 }
54 if len(got) >= len(big) {
55 t.Fatalf("oversize read was not shortened: got %d bytes, source %d", len(got), len(big))
56 }
57}
58
59func TestReadFileSchemaShape(t *testing.T) {
60 sch := ReadFileSchema()

Callers

nothing calls this directly

Calls 1

ReadFileFunction · 0.85

Tested by

no test coverage detected