TestEditFileOverlappingOldString: strings.Count sees only one non-overlapping "==" in "a === b", but it matches at two positions with different results; the exactly-once guarantee must reject it.
(t *testing.T)
| 98 | // non-overlapping "==" in "a === b", but it matches at two positions with |
| 99 | // different results; the exactly-once guarantee must reject it. |
| 100 | func TestEditFileOverlappingOldString(t *testing.T) { |
| 101 | dir := t.TempDir() |
| 102 | path := filepath.Join(dir, "f.txt") |
| 103 | if err := os.WriteFile(path, []byte("a === b"), 0o644); err != nil { |
| 104 | t.Fatal(err) |
| 105 | } |
| 106 | s := EditFile(path, "==", "XX") |
| 107 | if !strings.Contains(s, "(ambiguous") { |
| 108 | t.Fatalf("self-overlapping old_string must be ambiguous, got %q", s) |
| 109 | } |
| 110 | got, _ := os.ReadFile(path) |
| 111 | if string(got) != "a === b" { |
| 112 | t.Fatalf("file modified on ambiguity: %q", got) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | func TestEditFileNoOp(t *testing.T) { |
| 117 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected