(t *testing.T)
| 126 | // not apply - the exactly-once guarantee holds in the fuzzy path too. |
| 127 | func 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 | |
| 143 | func TestEditFileOldNotUnique(t *testing.T) { |
| 144 | dir := t.TempDir() |
| 145 | path := filepath.Join(dir, "f.txt") |
nothing calls this directly
no test coverage detected