summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Daskalakis <td@axiros.com>2019-07-15 14:20:27 +0200
committerAndy McCurdy <andy@andymccurdy.com>2019-07-17 15:49:02 -0700
commit5faed95b3b248d7d076298afd357a042cf916757 (patch)
tree7c1f1c2fa8ec5fe476ef31ead77ad6ccac5741a3 /tests
parentacac4db0c064d2618d75f27a58384c97c16458fd (diff)
downloadredis-py-5faed95b3b248d7d076298afd357a042cf916757.tar.gz
Handle removed claimed messages without an exception
Fixes #1191
Diffstat (limited to 'tests')
-rw-r--r--tests/test_commands.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 64cabdf..a41e1a2 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -1909,6 +1909,31 @@ class TestRedisCommands(object):
justid=True) == [message_id]
@skip_if_server_version_lt('5.0.0')
+ def test_xclaim_trimmed(self, r):
+ # xclaim should not raise an exception if the item is not there
+ stream = 'stream'
+ group = 'group'
+
+ r.xgroup_create(stream, group, id="$", mkstream=True)
+
+ # add a couple of new items
+ sid1 = r.xadd(stream, {"item": 0})
+ sid2 = r.xadd(stream, {"item": 0})
+
+ # read them from consumer1
+ r.xreadgroup(group, 'consumer1', {stream: ">"})
+
+ # add a 3rd and trim the stream down to 2 items
+ r.xadd(stream, {"item": 3}, maxlen=2, approximate=False)
+
+ # xclaim them from consumer2
+ # the item that is still in the stream should be returned
+ item = r.xclaim(stream, group, 'consumer2', 0, [sid1, sid2])
+ assert len(item) == 2
+ assert item[0] == (None, None)
+ assert item[1][0] == sid2
+
+ @skip_if_server_version_lt('5.0.0')
def test_xdel(self, r):
stream = 'stream'