diff --git a/tests/gateway/test_clean_shutdown_marker.py b/tests/gateway/test_clean_shutdown_marker.py index 1a476bc49a..c6d3cab5c1 100644 --- a/tests/gateway/test_clean_shutdown_marker.py +++ b/tests/gateway/test_clean_shutdown_marker.py @@ -49,9 +49,10 @@ class TestSuspendRecentlyActive: count = store.suspend_recently_active() assert count == 1 - # Re-fetch — should be suspended now + # Re-fetch — should be resume_pending (preserved, not wiped) refreshed = store.get_or_create_session(source) - assert refreshed.was_auto_reset + assert refreshed.resume_pending + assert refreshed.session_id == entry.session_id # same session preserved def test_does_not_suspend_old_sessions(self, tmp_path): store = _make_store(tmp_path) @@ -66,21 +67,22 @@ class TestSuspendRecentlyActive: count = store.suspend_recently_active(max_age_seconds=120) assert count == 0 - def test_already_suspended_not_double_counted(self, tmp_path): + def test_already_resume_pending_not_double_counted(self, tmp_path): store = _make_store(tmp_path) source = _make_source() entry = store.get_or_create_session(source) - # Suspend once + # Mark resume_pending once count1 = store.suspend_recently_active() assert count1 == 1 - # Create a new session (the old one got reset on next access) + # Re-fetch returns the SAME session (preserved, not reset) entry2 = store.get_or_create_session(source) + assert entry2.session_id == entry.session_id - # Suspend again — the new session is recent but not yet suspended + # Second call skips already-resume_pending entries count2 = store.suspend_recently_active() - assert count2 == 1 + assert count2 == 0 # --------------------------------------------------------------------------- @@ -180,11 +182,11 @@ class TestCleanShutdownMarker: else: store.suspend_recently_active() - # Session SHOULD be suspended (crash recovery) + # Session SHOULD be resume_pending (crash recovery preserves history) with store._lock: store._ensure_loaded_locked() - suspended_count = sum(1 for e in store._entries.values() if e.suspended) - assert suspended_count == 1, "Session should be suspended after crash (no marker)" + resume_count = sum(1 for e in store._entries.values() if e.resume_pending) + assert resume_count == 1, "Session should be resume_pending after crash (no marker)" def test_marker_written_on_restart_stop(self, tmp_path, monkeypatch): """stop(restart=True) should also write the marker.""" diff --git a/tests/gateway/test_restart_resume_pending.py b/tests/gateway/test_restart_resume_pending.py index 77c639d05f..bda6c7a412 100644 --- a/tests/gateway/test_restart_resume_pending.py +++ b/tests/gateway/test_restart_resume_pending.py @@ -376,8 +376,8 @@ class TestSuspendRecentlyActiveSkipsResumePending: assert e.suspended is False assert e.resume_pending is True - def test_non_resume_pending_still_suspended(self, tmp_path): - """Non-resume sessions still get the old crash-recovery suspension.""" + def test_non_resume_pending_gets_resume_pending(self, tmp_path): + """Non-resume sessions are now marked resume_pending (not suspended).""" store = _make_store(tmp_path) source_a = _make_source(chat_id="a") source_b = _make_source(chat_id="b") @@ -386,9 +386,11 @@ class TestSuspendRecentlyActiveSkipsResumePending: store.mark_resume_pending(entry_a.session_key) count = store.suspend_recently_active() + # entry_a is already resume_pending → skipped. entry_b gets marked. assert count == 1 assert store._entries[entry_a.session_key].suspended is False - assert store._entries[entry_b.session_key].suspended is True + assert store._entries[entry_b.session_key].resume_pending is True + assert store._entries[entry_b.session_key].suspended is False # ---------------------------------------------------------------------------