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

Function TestEditFileSchemaShape

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

Source from the content-addressed store, hash-verified

217 if string(got) != "alpha gamma" {
218 t.Fatalf("content wrong: %q", got)
219 }
220}
221
222func TestEditFileMultilineOldString(t *testing.T) {
223 dir := t.TempDir()
224 path := filepath.Join(dir, "f.txt")
225 src := "func foo() {\n\treturn 1\n}\n"
226 if err := os.WriteFile(path, []byte(src), 0o644); err != nil {
227 t.Fatal(err)
228 }
229 s := EditFile(path, "\treturn 1\n", "\treturn 42\n")
230 if !strings.HasPrefix(s, "edited") {
231 t.Fatalf("bad: %q", s)
232 }
233 got, _ := os.ReadFile(path)
234 if string(got) != "func foo() {\n\treturn 42\n}\n" {
235 t.Fatalf("content wrong: %q", got)
236 }
237}
238
239func TestExecuteEditFileWrapsResult(t *testing.T) {
240 dir := t.TempDir()
241 path := filepath.Join(dir, "f.txt")
242 if err := os.WriteFile(path, []byte("hello world"), 0o644); err != nil {
243 t.Fatal(err)
244 }

Callers

nothing calls this directly

Calls 1

EditFileSchemaFunction · 0.85

Tested by

no test coverage detected