test(pi): inject invalid persisted root after path validation

This commit is contained in:
Sycun committed 2026-11-12 21:29:58 +08:00
1 parent 634e823739
commit f44cf8b1dd
1 file changed
+4 -4
+4 -4
View File
@@ -110,11 +110,11 @@ func TestDeleteTurnRollsBackWhenPiCleanupFails(t *testing.T) {
if err != nil {
t.Fatal(err)
}
// A regular file as the parent is treated as an absent target by Windows
// RemoveAll. NUL is invalid on every supported OS and reliably exercises
// the cleanup error/transaction rollback path without filesystem privileges.
// Simulate an unusable persisted root. Inject it directly because Windows
// rejects NUL in filepath.Abs before registration, while Unix rejects it
// during removal. This reaches cleanup on both systems without privileges.
blocked := filepath.Join(root, "invalid\x00root")
if err := db.SetAgentSessionDir(blocked); err != nil {
if _, err := db.Exec(`INSERT INTO pi_session_roots (path) VALUES (?)`, blocked); err != nil {
t.Fatal(err)
}
if _, err := db.DeleteConversationTurn(conv.ID, msg.ID); err == nil {