summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-02-16 11:57:27 +0100
committerantirez <antirez@gmail.com>2018-03-15 12:54:10 +0100
commitc2ecac4746abbaf95617cc2d4ffaa54cdcf97990 (patch)
tree44135beb87e857b36a25db25bdd3752fe6aab206
parent18ab0e31f3cc95eb22b6f104049e18910331b4e8 (diff)
downloadredis-c2ecac4746abbaf95617cc2d4ffaa54cdcf97990.tar.gz
CG: test XGROUPREAD abilities.
-rw-r--r--tests/unit/type/stream-cgroups.tcl30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/type/stream-cgroups.tcl b/tests/unit/type/stream-cgroups.tcl
index 9a657a9ed..be53d5a53 100644
--- a/tests/unit/type/stream-cgroups.tcl
+++ b/tests/unit/type/stream-cgroups.tcl
@@ -8,4 +8,34 @@ start_server {
catch {r XGROUP CREATE mystream mygroup $} err
set err
} {BUSYGROUP*}
+
+ test {XREADGROUP will return only new elements} {
+ r XADD mystream * a 1
+ r XADD mystream * b 2
+ # XREADGROUP should return only the new elements "a 1" "b 1"
+ # and not the element "foo bar" which was pre existing in the
+ # stream (see previous test)
+ set reply [
+ r XREADGROUP GROUP mygroup client-1 STREAMS mystream ">"
+ ]
+ assert {[llength [lindex $reply 0 1]] == 2}
+ lindex $reply 0 1 0 1
+ } {a 1}
+
+ test {XREADGROUP can read the history of the elements we own} {
+ # Add a few more elements
+ r XADD mystream * c 3
+ r XADD mystream * d 4
+ # Read a few elements using a different consumer name
+ set reply [
+ r XREADGROUP GROUP mygroup client-2 STREAMS mystream ">"
+ ]
+ assert {[llength [lindex $reply 0 1]] == 2}
+ assert {[lindex $reply 0 1 0 1] eq {c 3}}
+
+ set r1 [r XREADGROUP GROUP mygroup client-1 COUNT 10 STREAMS mystream 0]
+ set r2 [r XREADGROUP GROUP mygroup client-2 COUNT 10 STREAMS mystream 0]
+ assert {[lindex $r1 0 1 0 1] eq {a 1}}
+ assert {[lindex $r2 0 1 0 1] eq {c 3}}
+ }
}