Add test verifying PUBSUB NUMPAT behavior (#9209)

(cherry picked from commit 8b8f05c86c1f1f002caa1f4e1877020389f167e4)
This commit is contained in:
Madelyn Olson 2021-09-03 15:52:39 -07:00 committed by Oran Agra
parent c936f801c0
commit 49f8f43890

View File

@ -152,6 +152,24 @@ start_server {tags {"pubsub network"}} {
r pubsub numsub abc def r pubsub numsub abc def
} {abc 0 def 0} } {abc 0 def 0}
test "NUMPATs returns the number of unique patterns" {
set rd1 [redis_deferring_client]
set rd2 [redis_deferring_client]
# Three unique patterns and one that overlaps
psubscribe $rd1 "foo*"
psubscribe $rd2 "foo*"
psubscribe $rd1 "bar*"
psubscribe $rd2 "baz*"
set patterns [r pubsub numpat]
# clean up clients
punsubscribe $rd1
punsubscribe $rd2
assert_equal 3 $patterns
}
test "Mix SUBSCRIBE and PSUBSCRIBE" { test "Mix SUBSCRIBE and PSUBSCRIBE" {
set rd1 [redis_deferring_client] set rd1 [redis_deferring_client]
assert_equal {1} [subscribe $rd1 {foo.bar}] assert_equal {1} [subscribe $rd1 {foo.bar}]