From 537e64e94680b75826949af46e95f3507bdf66a8 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Mon, 22 Nov 2010 10:31:57 +0100 Subject: [PATCH] Tests for behavior when connecting fails --- test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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");