Skip to content

Commit 47c3ece

Browse files
Merge pull request #1062 from yossigo/fix-push-notification-order
Handle push notifications before or after reply.
2 parents e23d91c + b455b33 commit 47c3ece

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test.c

+11
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,11 @@ static void test_resp3_push_handler(redisContext *c) {
914914
old = redisSetPushCallback(c, push_handler);
915915
test("We can set a custom RESP3 PUSH handler: ");
916916
reply = redisCommand(c, "SET key:0 val:0");
917+
/* We need another command because depending on the version of Redis, the
918+
* notification may be delivered after the command's reply. */
919+
test_cond(reply != NULL);
920+
freeReplyObject(reply);
921+
reply = redisCommand(c, "PING");
917922
test_cond(reply != NULL && reply->type == REDIS_REPLY_STATUS && pc.str == 1);
918923
freeReplyObject(reply);
919924

@@ -929,6 +934,12 @@ static void test_resp3_push_handler(redisContext *c) {
929934
assert((reply = redisCommand(c, "GET key:0")) != NULL);
930935
freeReplyObject(reply);
931936
assert((reply = redisCommand(c, "SET key:0 invalid")) != NULL);
937+
/* Depending on Redis version, we may receive either push notification or
938+
* status reply. Both cases are valid. */
939+
if (reply->type == REDIS_REPLY_STATUS) {
940+
freeReplyObject(reply);
941+
reply = redisCommand(c, "PING");
942+
}
932943
test_cond(reply->type == REDIS_REPLY_PUSH);
933944
freeReplyObject(reply);
934945

0 commit comments

Comments
 (0)