diff --git a/docs/about/changelog.md b/docs/about/changelog.md index 08121d80..d48125a0 100644 --- a/docs/about/changelog.md +++ b/docs/about/changelog.md @@ -7,6 +7,12 @@ tags: toc_depth: 2 --- +## v2.26.2 + +### 🐛 Bug Fixes + +- Fix bug in `xreadgroup` when stream length is less than COUNT with BLOCK #344 + ## v2.26.1 ### 🐛 Bug Fixes diff --git a/fakeredis/commands_mixins/streams_mixin.py b/fakeredis/commands_mixins/streams_mixin.py index ff3a34d2..be8cee63 100644 --- a/fakeredis/commands_mixins/streams_mixin.py +++ b/fakeredis/commands_mixins/streams_mixin.py @@ -341,7 +341,7 @@ def _xreadgroup( res: List[Any] = list() for group, stream_name, start_id in group_params: stream_results = group.group_read(consumer_name, start_id, count, noack) - if first_pass and (count is None or len(stream_results) < count): + if first_pass and (count is None): return None if len(stream_results) > 0 or start_id != b">": res.append([stream_name, stream_results]) diff --git a/pyproject.toml b/pyproject.toml index fc11078c..671899b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ packages = [ { include = "fakeredis" }, { include = "LICENSE", to = "fakeredis" }, ] -version = "2.26.1" +version = "2.26.2" description = "Python implementation of redis API, can be used for testing purposes." readme = "README.md" keywords = ["redis", "RedisJson", "RedisBloom", "tests", "redis-stack"] diff --git a/test/test_mixins/test_streams_commands.py b/test/test_mixins/test_streams_commands.py index f7e884cf..65058fac 100644 --- a/test/test_mixins/test_streams_commands.py +++ b/test/test_mixins/test_streams_commands.py @@ -812,3 +812,14 @@ def test_stream_ttl(r: redis.Redis): assert r.xread(streams={stream: 0}) == expected assert r.xtrim(stream, 0) == 1 assert r.ttl(stream) == -1 + + +def test_xreadgroup_length_less_than_count(r: redis.Redis): + r.xadd("test-events", {"message": "hello"}) + r.xadd("test-events", {"message": "bye"}) + + r.xgroup_create("test-events", "group1", id="0", mkstream=True) + messages = r.xreadgroup( + groupname="group1", consumername="consumer1", streams={"test-events": ">"}, count=10, block=2000 + ) + assert len(messages) == 1