diff options
author | Michael Grunder <michael.grunder@gmail.com> | 2022-04-23 14:31:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-23 14:31:09 -0700 |
commit | 47c3ecefc04505dcc8e42b9f726fc29aa8084bec (patch) | |
tree | 1e38b7f4ae755227ab67baf7d78acfbe9155592f | |
parent | e23d91c97b69c95e4131f3398fe1f3bafc1e7c33 (diff) | |
parent | b455b33818be4dab51777433fcac0d15e0c221ec (diff) |
Merge pull request #1062 from yossigo/fix-push-notification-order
Handle push notifications before or after reply.
-rw-r--r-- | test.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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); |