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

Function TestEditFileEmptyOldString

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

Source from the content-addressed store, hash-verified

126// not apply - the exactly-once guarantee holds in the fuzzy path too.
127func TestEditFileWhitespaceFuzzyAmbiguousFails(t *testing.T) {
128 dir := t.TempDir()
129 path := filepath.Join(dir, "f.txt")
130 const orig = "\tfoo bar\nx\n foo bar\n"
131 if err := os.WriteFile(path, []byte(orig), 0o644); err != nil {
132 t.Fatal(err)
133 }
134 s := EditFile(path, "foo bar", "baz") // double space: no exact match anywhere
135 if !strings.Contains(s, "not found") {
136 t.Fatalf("ambiguous fuzzy match must fail, got %q", s)
137 }
138 if got, _ := os.ReadFile(path); string(got) != orig {
139 t.Fatalf("file modified on ambiguous fuzzy match: %q", got)
140 }
141}
142
143func TestEditFileOldNotUnique(t *testing.T) {
144 dir := t.TempDir()
145 path := filepath.Join(dir, "f.txt")

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected