MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestEditFileWhitespaceNearMissHint

Function TestEditFileWhitespaceNearMissHint

internal/tools/edit_test.go:65–79  ·  view source on GitHub ↗

TestEditFileWhitespaceNearMissHint: a miss whose only difference is indentation gets the diagnostic hint, and the file is left untouched (the hint is detection only, never a fuzzy apply).

(t *testing.T)

Source from the content-addressed store, hash-verified

63// indentation gets the diagnostic hint, and the file is left untouched (the
64// hint is detection only, never a fuzzy apply).
65func TestEditFileWhitespaceNearMissHint(t *testing.T) {
66 dir := t.TempDir()
67 path := filepath.Join(dir, "f.go")
68 const orig = "func main() {\n\treturn 1\n}\n" // file indents with a tab
69 if err := os.WriteFile(path, []byte(orig), 0o644); err != nil {
70 t.Fatal(err)
71 }
72 s := EditFile(path, " return 1", " return 2") // model supplied spaces
73 if !strings.Contains(s, "differs only in whitespace") {
74 t.Fatalf("want whitespace near-miss hint, got %q", s)
75 }
76 if got, _ := os.ReadFile(path); string(got) != orig {
77 t.Fatalf("file modified on near-miss: %q", got)
78 }
79}
80
81func TestEditFileOldNotUnique(t *testing.T) {
82 dir := t.TempDir()

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected