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

Function TestExecuteReadFileWrapsResult

internal/tools/read_test.go:85–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

83 if err := os.WriteFile(path, []byte(want), 0o644); err != nil {
84 t.Fatal(err)
85 }
86 var got strings.Builder
87 for offset := 1; offset <= 900; offset += 100 {
88 page := ReadFile(path, offset, 100)
89 if i := strings.Index(page, "\n\n[lines "); i >= 0 {
90 page = page[:i] + "\n"
91 }
92 got.WriteString(page)
93 }
94 if got.String() != want {
95 t.Fatalf("paged read did not reconstruct the file: got %d bytes, want %d", got.Len(), len(want))
96 }
97}
98
99// TestReadFileOffsetPastEnd: a bad offset must say so, not return an empty
100// string the model would read as "the file is empty".
101func TestReadFileOffsetPastEnd(t *testing.T) {
102 dir := t.TempDir()
103 path := filepath.Join(dir, "small.txt")
104 if err := os.WriteFile(path, []byte("a\nb\n"), 0o644); err != nil {
105 t.Fatal(err)
106 }
107 got := ReadFile(path, 99, 0)

Callers

nothing calls this directly

Calls 1

ExecuteFunction · 0.85

Tested by

no test coverage detected