MCPcopy Create free account
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 t.Fatalf("result must name the matched lines, got %q", s)
80 }
81 if got, _ := os.ReadFile(path); string(got) != "func main() {\n return 2\n}\n" {
82 t.Fatalf("bad fuzzy apply result: %q", got)
83 }
84}
85
86// TestEditFileWhitespaceFuzzyApplyMultiline: an indent-shifted multi-line
87// block applies, preserving the lines around it byte-exactly.
88func TestEditFileWhitespaceFuzzyApplyMultiline(t *testing.T) {
89 dir := t.TempDir()
90 path := filepath.Join(dir, "f.py")
91 const orig = "def f():\n if x:\n do(1)\n do(2)\n return\n"
92 if err := os.WriteFile(path, []byte(orig), 0o644); err != nil {
93 t.Fatal(err)
94 }
95 // Model retyped the block one indent level off.
96 s := EditFile(path, "if x:\n do(1)\n do(2)", " if y:\n do(1)\n do(2)")
97 if !strings.Contains(s, "edited") {
98 t.Fatalf("want fuzzy apply, got %q", s)

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected