diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-02 10:06:21 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-02 10:06:21 +0100 |
commit | fd841e416881cc0392e61ec312c1870f3a0004bd (patch) | |
tree | 8357ba56e79d614ba57f722e7878b853591dc339 /tests/unit/mongo/client/connect.c |
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'tests/unit/mongo/client/connect.c')
-rw-r--r-- | tests/unit/mongo/client/connect.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/unit/mongo/client/connect.c b/tests/unit/mongo/client/connect.c new file mode 100644 index 0000000..fc390ea --- /dev/null +++ b/tests/unit/mongo/client/connect.c @@ -0,0 +1,34 @@ +#include "test.h" +#include "tap.h" +#include "mongo-client.h" + +#include <errno.h> + +void +test_mongo_connect (void) +{ + mongo_connection *c; + + ok (mongo_connect (NULL, 27010) == NULL, + "mongo_connect() fails with a NULL host"); + ok (errno == EINVAL, + "mongo_connect() should fail with EINVAL if host is NULL"); + + begin_network_tests (4); + + ok (mongo_connect ("invalid.example.com", 27017) == NULL, + "Connecting to an invalid host fails"); + ok (mongo_connect ("example.com", 27017) == NULL, + "Connecting to an unavailable host/port fails"); + ok (mongo_connect ("/does/not/exist.sock", MONGO_CONN_LOCAL) == NULL, + "Connecting to an unavailable unix socket fails"); + + ok ((c = mongo_connect (config.primary_host, + config.primary_port)) != NULL, + "Connecting to the primary server works"); + mongo_disconnect (c); + + end_network_tests (); +} + +RUN_TEST (6, mongo_connect); |