MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestEditFileHappy

Function TestEditFileHappy

internal/tools/edit_test.go:13–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func 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
32func TestEditFileEmptyPath(t *testing.T) {
33 if got := EditFile("", "x", "y"); got != "(empty path)" {

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected