(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestEditFileHappy(t *testing.T) { |
| 14 | dir := t.TempDir() |
| 15 | path := filepath.Join(dir, "hello.txt") |
| 16 | if err := os.WriteFile(path, []byte("alpha beta gamma\n"), 0o644); err != nil { |
| 17 | t.Fatal(err) |
| 18 | } |
| 19 | s := EditFile(path, "beta", "BRAVO") |
| 20 | if !strings.HasPrefix(s, "edited") { |
| 21 | t.Fatalf("status wrong: %q", s) |
| 22 | } |
| 23 | got, err := os.ReadFile(path) |
| 24 | if err != nil { |
| 25 | t.Fatalf("readback: %v", err) |
| 26 | } |
| 27 | if string(got) != "alpha BRAVO gamma\n" { |
| 28 | t.Fatalf("content wrong: %q", got) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | func TestEditFileEmptyPath(t *testing.T) { |
| 33 | if got := EditFile("", "x", "y"); got != "(empty path)" { |
nothing calls this directly
no test coverage detected