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// TestEditFileOverlappingOldString: strings.Count sees only one
160// non-overlapping "==" in "a === b", but it matches at two positions with
161// different results; the exactly-once guarantee must reject it.
162func TestEditFileOverlappingOldString(t *testing.T) {
163 dir := t.TempDir()
164 path := filepath.Join(dir, "f.txt")
165 if err := os.WriteFile(path, []byte("a === b"), 0o644); err != nil {
166 t.Fatal(err)
167 }
168 s := EditFile(path, "==", "XX")
169 if !strings.Contains(s, "(ambiguous") {
170 t.Fatalf("self-overlapping old_string must be ambiguous, got %q", s)
171 }
172 got, _ := os.ReadFile(path)
173 if string(got) != "a === b" {
174 t.Fatalf("file modified on ambiguity: %q", got)
175 }
176}
177
178func TestEditFileNoOp(t *testing.T) {

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected