summaryrefslogtreecommitdiff
path: root/test.c
diff options
context:
space:
mode:
authorYossi Gottlieb <yossigo@gmail.com>2022-04-22 15:35:55 +0300
committerYossi Gottlieb <yossigo@gmail.com>2022-04-22 15:35:55 +0300
commitb455b33818be4dab51777433fcac0d15e0c221ec (patch)
tree1bfb7771c36235316f380add9665984041bb5e23 /test.c
parentd7683f35aa66e222aad07caf5b345393d0c1b9f1 (diff)
Handle push notifications before or after reply.
Diffstat (limited to 'test.c')
-rw-r--r--test.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/test.c b/test.c
index f43bc24..b831680 100644
--- a/test.c
+++ b/test.c
@@ -914,6 +914,11 @@ static void test_resp3_push_handler(redisContext *c) {
old = redisSetPushCallback(c, push_handler);
test("We can set a custom RESP3 PUSH handler: ");
reply = redisCommand(c, "SET key:0 val:0");
+ /* We need another command because depending on the version of Redis, the
+ * notification may be delivered after the command's reply. */
+ test_cond(reply != NULL);
+ freeReplyObject(reply);
+ reply = redisCommand(c, "PING");
test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && pc.str == 1);
freeReplyObject(reply);
@@ -929,6 +934,12 @@ static void test_resp3_push_handler(redisContext *c) {
assert((reply = redisCommand(c, "GET key:0")) != NULL);
freeReplyObject(reply);
assert((reply = redisCommand(c, "SET key:0 invalid")) != NULL);
+ /* Depending on Redis version, we may receive either push notification or
+ * status reply. Both cases are valid. */
+ if (reply->type == REDIS_REPLY_STATUS) {
+ freeReplyObject(reply);
+ reply = redisCommand(c, "PING");
+ }
test_cond(reply->type == REDIS_REPLY_PUSH);
freeReplyObject(reply);