(t *testing.T)
| 217 | if string(got) != "alpha gamma" { |
| 218 | t.Fatalf("content wrong: %q", got) |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | func TestEditFileMultilineOldString(t *testing.T) { |
| 223 | dir := t.TempDir() |
| 224 | path := filepath.Join(dir, "f.txt") |
| 225 | src := "func foo() {\n\treturn 1\n}\n" |
| 226 | if err := os.WriteFile(path, []byte(src), 0o644); err != nil { |
| 227 | t.Fatal(err) |
| 228 | } |
| 229 | s := EditFile(path, "\treturn 1\n", "\treturn 42\n") |
| 230 | if !strings.HasPrefix(s, "edited") { |
| 231 | t.Fatalf("bad: %q", s) |
| 232 | } |
| 233 | got, _ := os.ReadFile(path) |
| 234 | if string(got) != "func foo() {\n\treturn 42\n}\n" { |
| 235 | t.Fatalf("content wrong: %q", got) |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | func TestExecuteEditFileWrapsResult(t *testing.T) { |
| 240 | dir := t.TempDir() |
| 241 | path := filepath.Join(dir, "f.txt") |
| 242 | if err := os.WriteFile(path, []byte("hello world"), 0o644); err != nil { |
| 243 | t.Fatal(err) |
| 244 | } |
nothing calls this directly
no test coverage detected