TestMultipatch_HappyPathSingleFile is the smoke test: one edit against one file lands cleanly. Mirrors handlePatch but goes through the new transactional code path.
(t *testing.T)
| 50 | // against one file lands cleanly. Mirrors handlePatch but goes |
| 51 | // through the new transactional code path. |
| 52 | func TestMultipatch_HappyPathSingleFile(t *testing.T) { |
| 53 | dir := t.TempDir() |
| 54 | path := writeFile(t, dir, "a.txt", "hello world\n") |
| 55 | eng, out, _ := newTestEngine(t, dir) |
| 56 | |
| 57 | editsJSON := `[{"file":"` + path + `","search":"hello","replace":"goodbye"}]` |
| 58 | err := eng.Execute(context.Background(), "multipatch", []string{"--edits", editsJSON}) |
| 59 | require.NoError(t, err) |
| 60 | assert.Equal(t, "goodbye world\n", readFile(t, path)) |
| 61 | assert.Contains(t, out.String(), "multipatch") |
| 62 | assert.Contains(t, out.String(), "applied 1 edit") |
| 63 | } |
| 64 | |
| 65 | // TestMultipatch_HappyPathMultipleFiles confirms cross-file atomic |
| 66 | // commit: three files, three edits, all land in one transaction. |