summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-01-21 18:50:16 +0100
committerantirez <antirez@gmail.com>2013-01-21 19:02:26 +0100
commit2039f1a38ac23311abc71fc7d862d9e5b22598c6 (patch)
tree8e3e04f5f1c0c5b0ebbc2eeb07af4d30f709d770 /tests
parent93f61bb2a492cf008e353db951275ba0b12490dc (diff)
downloadredis-2039f1a38ac23311abc71fc7d862d9e5b22598c6.tar.gz
UNSUBSCRIBE and PUNSUBSCRIBE: always provide a reply.
UNSUBSCRIBE and PUNSUBSCRIBE commands are designed to mass-unsubscribe the client respectively all the channels and patters if called without arguments. However when these functions are called without arguments, but there are no channels or patters we are subscribed to, the old behavior was to don't reply at all. This behavior is broken, as every command should always reply. Also it is possible that we are no longer subscribed to a channels but we are subscribed to patters or the other way around, and the client should be notified with the correct number of subscriptions. Also it is not pretty that sometimes we did not receive a reply at all in a redis-cli session from these commands, blocking redis-cli trying to read the reply. This fixes issue #714.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/pubsub.tcl12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/unit/pubsub.tcl b/tests/unit/pubsub.tcl
index c8b547b4f..769151600 100644
--- a/tests/unit/pubsub.tcl
+++ b/tests/unit/pubsub.tcl
@@ -192,4 +192,14 @@ start_server {tags {"pubsub"}} {
# clean up clients
$rd1 close
}
-} \ No newline at end of file
+
+ test "PUNSUBSCRIBE and UNSUBSCRIBE should always reply." {
+ # Make sure we are not subscribed to any channel at all.
+ r punsubscribe
+ r unsubscribe
+ # Now check if the commands still reply correctly.
+ set reply1 [r punsubscribe]
+ set reply2 [r unsubscribe]
+ concat $reply1 $reply2
+ } {punsubscribe {} 0 unsubscribe {} 0}
+}