(t *testing.T)
| 126 | } |
| 127 | |
| 128 | func TestEditFileEmptyOldString(t *testing.T) { |
| 129 | dir := t.TempDir() |
| 130 | path := filepath.Join(dir, "f.txt") |
| 131 | if err := os.WriteFile(path, []byte("abc"), 0o644); err != nil { |
| 132 | t.Fatal(err) |
| 133 | } |
| 134 | s := EditFile(path, "", "x") |
| 135 | if !strings.Contains(s, "empty") { |
| 136 | t.Fatalf("bad: %q", s) |
| 137 | } |
| 138 | got, _ := os.ReadFile(path) |
| 139 | if string(got) != "abc" { |
| 140 | t.Fatalf("file modified on empty old_string: %q", got) |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | func TestEditFileDelete(t *testing.T) { |
| 145 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected