Compare commits

...
Author SHA1 Message Date
mathiasandClaude Opus 5.5 cdcff126ef test(brain_edit): the rollback test proves the swap happened (#192)
CI / Lint / Test / Vet (pull_request) Successful in 1m6s
CI / Mirror to GitHub (pull_request) Skipped
Review round 2 on PR #194: with the hook made a no-op the test still
passed (no swap, the rollback wrote the real note, victim trivially
untouched). It now asserts the error says the edit could NOT be rolled
back and that the note path is still the swapped-in symlink; red when
the hook does not fire.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 23:43:27 +02:00
@@ -111,6 +111,12 @@ func TestBrainEditRollbackDoesNotWriteThroughASymlinkSwappedInForTheNote(t *test
})() })()
resp := authCall(t, srv, jwtAuthz, "brain_edit", map[string]any{"path": path, "old_str": "static body", "new_str": "injected"}) resp := authCall(t, srv, jwtAuthz, "brain_edit", map[string]any{"path": path, "old_str": "static body", "new_str": "injected"})
require.NotNil(t, resp["error"]) require.NotNil(t, resp["error"])
// The swap happened and the rollback refused it: the error says so,
// and the note path is still the planted symlink.
assert.Contains(t, resp["error"].(map[string]any)["message"], "could NOT be rolled back")
fi, err := os.Lstat(note)
require.NoError(t, err)
assert.NotZero(t, fi.Mode()&os.ModeSymlink, "the note path is still the swapped-in symlink")
got, _ := os.ReadFile(victim) got, _ := os.ReadFile(victim)
assert.Equal(t, "untouched", string(got), "the rollback wrote through the swapped-in symlink") assert.Equal(t, "untouched", string(got), "the rollback wrote through the swapped-in symlink")
}) })