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

Function TestEditFileMultilineOldString

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

Source from the content-addressed store, hash-verified

158}
159
160func TestEditFileMultilineOldString(t *testing.T) {
161 dir := t.TempDir()
162 path := filepath.Join(dir, "f.txt")
163 src := "func foo() {\n\treturn 1\n}\n"
164 if err := os.WriteFile(path, []byte(src), 0o644); err != nil {
165 t.Fatal(err)
166 }
167 s := EditFile(path, "\treturn 1\n", "\treturn 42\n")
168 if !strings.HasPrefix(s, "edited") {
169 t.Fatalf("bad: %q", s)
170 }
171 got, _ := os.ReadFile(path)
172 if string(got) != "func foo() {\n\treturn 42\n}\n" {
173 t.Fatalf("content wrong: %q", got)
174 }
175}
176
177func TestExecuteEditFileWrapsResult(t *testing.T) {
178 dir := t.TempDir()

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected