summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-11-22 10:31:57 +0100
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-11-22 10:32:37 +0100
commit537e64e94680b75826949af46e95f3507bdf66a8 (patch)
tree2f66c01c99d5b4ba83c217c6628181af9ed0acca
parent7c33f2666bd60a4bba1a67c155b11b757b043904 (diff)
Tests for behavior when connecting fails
-rw-r--r--test.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/test.c b/test.c
index 41d9a87..dd9d92f 100644
--- a/test.c
+++ b/test.c
@@ -96,6 +96,18 @@ static void test_blocking_connection() {
redisReply *reply;
int major, minor;
+ test("Returns error when host cannot be resolved: ");
+ c = redisConnect((char*)"idontexist.local", 6379);
+ test_cond(c->err == REDIS_ERR_OTHER &&
+ strcmp(c->errstr,"can't resolve: idontexist.local") == 0);
+ redisFree(c);
+
+ test("Returns error when the port is not open: ");
+ c = redisConnect((char*)"localhost", 56380);
+ test_cond(c->err == REDIS_ERR_IO &&
+ strcmp(c->errstr,"Connection refused") == 0);
+ redisFree(c);
+
__connect(&c);
test("Is able to deliver commands: ");
reply = redisCommand(c,"PING");