fix(backend): consume webview tickets atomically and fail closed on Redis errors.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
62161e2905
commit
98292cb914
2 files changed
+66
-27
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
@@ -22,6 +21,9 @@ class FakeRedis:
|
||||
def delete(self, key):
|
||||
return 1 if self.data.pop(key, None) is not None else 0
|
||||
|
||||
def getdel(self, key):
|
||||
return self.data.pop(key, None)
|
||||
|
||||
|
||||
def test_issue_and_consume_once():
|
||||
fake = FakeRedis()
|
||||
@@ -44,3 +46,9 @@ def test_issue_without_redis_raises():
|
||||
with patch.object(svc, "get_sync_redis_client", return_value=None):
|
||||
with pytest.raises(RuntimeError, match="Redis"):
|
||||
svc.issue_ticket("u1", "sid-1")
|
||||
|
||||
|
||||
def test_consume_without_redis_raises():
|
||||
with patch.object(svc, "get_sync_redis_client", return_value=None):
|
||||
with pytest.raises(RuntimeError, match="Redis"):
|
||||
svc.consume_ticket("any-ticket")
|
||||
Reference in new issue
Block a user