summaryrefslogtreecommitdiff
path: root/test.c
diff options
context:
space:
mode:
authorBjorn Svensson <bjorn.a.svensson@est.tech>2021-12-16 21:38:15 +0100
committerGitHub <noreply@github.com>2021-12-16 12:38:15 -0800
commitd3384260e7e1726747bd78474e4b0874a4b0a236 (patch)
treeac413c6734abad22e6244e9d91477e22e2275bf4 /test.c
parente3a479e4098dddbf0b075bbe81b0baca5fe0e3df (diff)
Support PING while subscribing (RESP2) (#1027)
* Handle PING during pubsub in RESP2 * Rename invalid callback list Some commands are valid to send during a subscribe in RESP2, and most in RESP3. Renaming the callback list from `invalid` to `replies` to detail this fact. * Fix review comment
Diffstat (limited to 'test.c')
-rw-r--r--test.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/test.c b/test.c
index 7af9bee..ec1c419 100644
--- a/test.c
+++ b/test.c
@@ -1518,6 +1518,15 @@ void subscribe_cb(redisAsyncContext *ac, void *r, void *privdata) {
}
}
+/* Expect a reply of type ARRAY */
+void array_cb(redisAsyncContext *ac, void *r, void *privdata) {
+ (void) ac;
+ redisReply *reply = r;
+ TestState *state = privdata;
+ assert(reply != NULL && reply->type == REDIS_REPLY_ARRAY);
+ state->checkpoint++;
+}
+
static void test_pubsub_handling(struct config config) {
test("Subscribe, handle published message and unsubscribe: ");
/* Setup event dispatcher with a testcase timeout */
@@ -1539,13 +1548,16 @@ static void test_pubsub_handling(struct config config) {
TestState state = {.options = &options};
redisAsyncCommand(ac,subscribe_cb,&state,"subscribe mychannel");
+ /* Make sure non-subscribe commands are handled */
+ redisAsyncCommand(ac,array_cb,&state,"PING");
+
/* Start event dispatching loop */
test_cond(event_base_dispatch(base) == 0);
event_free(timeout);
event_base_free(base);
/* Verify test checkpoints */
- assert(state.checkpoint == 1);
+ assert(state.checkpoint == 2);
}
/* Unexpected push message, will trigger a failure */