summaryrefslogtreecommitdiff
path: root/tests/unit/mongo/sync/sync_connect_cache.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-12-02 10:06:21 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-12-02 10:06:21 +0100
commitfd841e416881cc0392e61ec312c1870f3a0004bd (patch)
tree8357ba56e79d614ba57f722e7878b853591dc339 /tests/unit/mongo/sync/sync_connect_cache.c
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'tests/unit/mongo/sync/sync_connect_cache.c')
-rw-r--r--tests/unit/mongo/sync/sync_connect_cache.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/unit/mongo/sync/sync_connect_cache.c b/tests/unit/mongo/sync/sync_connect_cache.c
new file mode 100644
index 0000000..1618899
--- /dev/null
+++ b/tests/unit/mongo/sync/sync_connect_cache.c
@@ -0,0 +1,42 @@
+#include "test.h"
+#include "mongo.h"
+
+void
+test_mongo_sync_conn_recovery_cache_connection (void)
+{
+ mongo_sync_conn_recovery_cache *cache;
+ mongo_sync_connection *c = NULL;
+
+ cache = mongo_sync_conn_recovery_cache_new ();
+
+ ok (mongo_sync_connect_recovery_cache (cache, FALSE) == NULL,
+ "mongo_sync_connect_recovery_cache() should fail when cache is empty");
+
+ begin_network_tests (4);
+
+ ok (mongo_sync_conn_recovery_cache_seed_add (cache,
+ config.primary_host,
+ config.primary_port) == TRUE,
+ "mongo_sync_conn_recovery_cache_seed_add() works");
+
+ ok ((c = mongo_sync_connect_recovery_cache (cache, FALSE)) != NULL,
+ "mongo_sync_connect_recovery_cache() works");
+
+ mongo_sync_disconnect (c);
+
+ ok ((c = mongo_sync_connect_recovery_cache (cache, FALSE)) != NULL,
+ "mongo_sync_connect_recovery_cache() works after disconnect");
+
+ mongo_sync_disconnect (c);
+
+ mongo_sync_conn_recovery_cache_discard (cache);
+
+ ok (mongo_sync_connect_recovery_cache (cache, TRUE) == NULL,
+ "mongo_sync_connect_recovery_cache() should fail when cache is discarded");
+
+ mongo_sync_conn_recovery_cache_free (cache);
+
+ end_network_tests ();
+}
+
+RUN_TEST (5, mongo_sync_conn_recovery_cache_connection);