pubsub: Return integers for NUMSUB, not strings

Also adds test for numsub — due to tcl being tcl,
it doesn't capture the "numberness" of the fix,
but now we at least have one test case for numsub.

Closes #1561
This commit is contained in:
Matt Stancliff 2014-08-01 13:57:30 -04:00 committed by antirez
parent 4bb6844e43
commit 25791550e0
2 changed files with 5 additions and 1 deletions

View File

@ -358,7 +358,7 @@ void pubsubCommand(redisClient *c) {
list *l = dictFetchValue(server.pubsub_channels,c->argv[j]); list *l = dictFetchValue(server.pubsub_channels,c->argv[j]);
addReplyBulk(c,c->argv[j]); addReplyBulk(c,c->argv[j]);
addReplyBulkLongLong(c,l ? listLength(l) : 0); addReplyLongLong(c,l ? listLength(l) : 0);
} }
} else if (!strcasecmp(c->argv[1]->ptr,"numpat") && c->argc == 2) { } else if (!strcasecmp(c->argv[1]->ptr,"numpat") && c->argc == 2) {
/* PUBSUB NUMPAT */ /* PUBSUB NUMPAT */

View File

@ -196,6 +196,10 @@ start_server {tags {"pubsub"}} {
$rd1 close $rd1 close
} }
test "NUMSUB returns numbers, not strings (#1561)" {
r pubsub numsub abc def
} {abc 0 def 0}
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}]