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

Function TestExecuteEditFileWrapsResult

internal/tools/edit_test.go:177–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175 }
176}
177
178func TestEditFileNoOp(t *testing.T) {
179 dir := t.TempDir()
180 path := filepath.Join(dir, "f.txt")
181 if err := os.WriteFile(path, []byte("abc"), 0o644); err != nil {
182 t.Fatal(err)
183 }
184 s := EditFile(path, "x", "x")
185 if !strings.Contains(s, "no change") {
186 t.Fatalf("bad: %q", s)
187 }
188}
189
190func TestEditFileEmptyOldString(t *testing.T) {
191 dir := t.TempDir()
192 path := filepath.Join(dir, "f.txt")
193 if err := os.WriteFile(path, []byte("abc"), 0o644); err != nil {
194 t.Fatal(err)
195 }
196 s := EditFile(path, "", "x")
197 if !strings.Contains(s, "empty") {
198 t.Fatalf("bad: %q", s)
199 }
200 got, _ := os.ReadFile(path)
201 if string(got) != "abc" {
202 t.Fatalf("file modified on empty old_string: %q", got)
203 }
204}
205
206func TestEditFileDelete(t *testing.T) {

Callers

nothing calls this directly

Calls 1

ExecuteFunction · 0.85

Tested by

no test coverage detected