Skip to content

Commit 83bc236

Browse files
committed
test: add test for listing sessions sorted by recent
1 parent 5bd39d6 commit 83bc236

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_storage.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,21 @@ def test_list_sessions_with_limit(self, temp_storage, sample_context):
367367

368368
assert len(sessions) == 5
369369

370+
def test_list_sessions_sorted_by_recent(self, temp_storage, sample_context):
371+
"""Test that sessions are sorted by most recent first."""
372+
import time
373+
374+
temp_storage.save_session("session-1", sample_context)
375+
time.sleep(0.01)
376+
temp_storage.save_session("session-2", sample_context)
377+
time.sleep(0.01)
378+
temp_storage.save_session("session-3", sample_context)
379+
380+
sessions = temp_storage.list_sessions()
381+
382+
assert sessions[0]["id"] == "session-3"
383+
assert sessions[2]["id"] == "session-1"
384+
370385
def test_list_sessions_empty(self, temp_storage):
371386
"""Test listing sessions when none exist."""
372387
sessions = temp_storage.list_sessions()

0 commit comments

Comments
 (0)