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

Function TestEditFileOldNotUnique

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

Source from the content-addressed store, hash-verified

79}
80
81func TestEditFileOldNotUnique(t *testing.T) {
82 dir := t.TempDir()
83 path := filepath.Join(dir, "f.txt")
84 if err := os.WriteFile(path, []byte("foo bar foo"), 0o644); err != nil {
85 t.Fatal(err)
86 }
87 s := EditFile(path, "foo", "qux")
88 if !strings.Contains(s, "appears") || !strings.Contains(s, "2") {
89 t.Fatalf("bad: %q", s)
90 }
91 got, _ := os.ReadFile(path)
92 if string(got) != "foo bar foo" {
93 t.Fatalf("file modified on ambiguity: %q", got)
94 }
95}
96
97// TestEditFileOverlappingOldString: strings.Count sees only one
98// non-overlapping "==" in "a === b", but it matches at two positions with

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected