Skip to content

Commit

Permalink
Remove eventloop from testcases where it is superfluous
Browse files Browse the repository at this point in the history
  • Loading branch information
bjosv committed Sep 29, 2023
1 parent 5d7b2bf commit 03c0c2b
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions tests/ct_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,14 @@ void test_async_password_ok(void) {
event_base_free(base);
}

// Connecting to a password protected cluster using
// the async API, providing wrong password.
/* Connect to a password protected cluster using the wrong password.
An eventloop is not attached since it is not needed is this case. */
void test_async_password_wrong(void) {
redisClusterAsyncContext *acc = redisClusterAsyncContextInit();
assert(acc);
redisClusterAsyncSetConnectCallback(acc, callbackExpectOk);
redisClusterAsyncSetDisconnectCallback(acc, callbackExpectOk);
redisClusterSetOptionAddNodes(acc->cc, CLUSTER_NODE_WITH_PASSWORD);
redisClusterSetOptionPassword(acc->cc, "faultypass");

struct event_base *base = event_base_new();
redisClusterLibeventAttach(acc, base);

int ret;
ret = redisClusterConnect2(acc->cc);
assert(ret == REDIS_ERR);
Expand All @@ -401,14 +396,11 @@ void test_async_password_wrong(void) {
assert(acc->err == REDIS_ERR_OTHER);
assert(strcmp(acc->errstr, "slotmap not available") == 0);

event_base_dispatch(base);

redisClusterAsyncFree(acc);
event_base_free(base);
}

// Connecting to a password protected cluster using
// the async API, not providing a password.
/* Connect to a password protected cluster without providing a password.
An eventloop is not attached since it is not needed is this case. */
void test_async_password_missing(void) {
redisClusterAsyncContext *acc = redisClusterAsyncContextInit();
assert(acc);
Expand All @@ -417,9 +409,6 @@ void test_async_password_missing(void) {
redisClusterSetOptionAddNodes(acc->cc, CLUSTER_NODE_WITH_PASSWORD);
// Password not configured

struct event_base *base = event_base_new();
redisClusterLibeventAttach(acc, base);

int ret;
ret = redisClusterConnect2(acc->cc);
assert(ret == REDIS_ERR);
Expand All @@ -434,10 +423,7 @@ void test_async_password_missing(void) {
assert(acc->err == REDIS_ERR_OTHER);
assert(strcmp(acc->errstr, "slotmap not available") == 0);

event_base_dispatch(base);

redisClusterAsyncFree(acc);
event_base_free(base);
}

// Connect to a cluster and authenticate using username and password
Expand Down

0 comments on commit 03c0c2b

Please sign in to comment.