fix: reset() only drops history table, leaving stale messages (#5541)

This commit is contained in:
Hrushikesh Yadav
2026-06-22 11:28:17 +05:30
committed by GitHub
parent 871a1de7d2
commit 650b734b1b
4 changed files with 77 additions and 11 deletions
+19
View File
@@ -280,3 +280,22 @@ class TestSQLiteManager:
assert history[0]["actor_id"] is None
assert history[0]["is_deleted"] is False
mgr.close()
def test_reset_drops_tables(self, temp_db_path):
"""reset() must drop both history and messages tables."""
mgr = SQLiteManager(temp_db_path)
mgr.add_history(memory_id="m1", old_memory=None, new_memory="new", event="ADD")
mgr.save_messages([{"role": "user", "content": "hello", "name": None}], "sess1")
mgr.reset()
tables = mgr.connection.execute(
"SELECT name FROM sqlite_master WHERE type='table' AND name IN ('history','messages')"
).fetchall()
assert tables == [], "both tables should be dropped after reset"
mgr.close()
mgr2 = SQLiteManager(temp_db_path)
msg_count = mgr2.connection.execute("SELECT COUNT(*) FROM messages").fetchone()[0]
hist_count = mgr2.connection.execute("SELECT COUNT(*) FROM history").fetchone()[0]
assert msg_count == 0
assert hist_count == 0
mgr2.close()