Skip to content

Commit

Permalink
Add test of re-registration of connect callback
Browse files Browse the repository at this point in the history
  • Loading branch information
bjosv committed Mar 15, 2024
1 parent 5501d2b commit 5f72470
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/ct_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ void connectCallback(const redisAsyncContext *ac, int status) {
printf("Connected to %s:%d\n", ac->c.tcp.host, ac->c.tcp.port);
}

#ifndef HIRCLUSTER_NO_NONCONST_CONNECT_CB
void connectCallbackNC(redisAsyncContext *ac, int status) {
UNUSED(ac);
UNUSED(status);
/* The testcase expects a failure during registration of
this non-async connect callback. */
assert(0);
}
#endif

void disconnectCallback(const redisAsyncContext *ac, int status) {
ASSERT_MSG(status == REDIS_OK, ac->errstr);
printf("Disconnected from %s:%d\n", ac->c.tcp.host, ac->c.tcp.port);
Expand Down Expand Up @@ -66,6 +76,14 @@ int main(void) {
int status;
status = redisClusterAsyncSetConnectCallback(acc, connectCallback);
assert(status == REDIS_OK);
status = redisClusterAsyncSetConnectCallback(acc, connectCallback);
assert(status == REDIS_ERR); /* Re-registration not accepted */

#ifndef HIRCLUSTER_NO_NONCONST_CONNECT_CB
status = redisClusterAsyncSetConnectCallbackNC(acc, connectCallbackNC);
assert(status == REDIS_ERR); /* Re-registration not accepted */
#endif

status = redisClusterAsyncSetDisconnectCallback(acc, disconnectCallback);
assert(status == REDIS_OK);
status = redisClusterSetEventCallback(acc->cc, eventCallback, acc);
Expand Down

0 comments on commit 5f72470

Please sign in to comment.