summaryrefslogtreecommitdiff
path: root/tests/unit/mongo/sync/sync_get_set_slaveok.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_get_set_slaveok.c
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'tests/unit/mongo/sync/sync_get_set_slaveok.c')
-rw-r--r--tests/unit/mongo/sync/sync_get_set_slaveok.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/unit/mongo/sync/sync_get_set_slaveok.c b/tests/unit/mongo/sync/sync_get_set_slaveok.c
new file mode 100644
index 0000000..7a43979
--- /dev/null
+++ b/tests/unit/mongo/sync/sync_get_set_slaveok.c
@@ -0,0 +1,38 @@
+#include "test.h"
+#include "mongo.h"
+
+#include <errno.h>
+
+void
+test_mongo_sync_get_set_slaveok (void)
+{
+ mongo_sync_connection *c;
+
+ c = test_make_fake_sync_conn (-1, FALSE);
+
+ errno = 0;
+ ok (mongo_sync_conn_get_slaveok (NULL) == FALSE,
+ "mongo_sync_conn_get_slaveok() returns FALSE with a NULL connection");
+ cmp_ok (errno, "==", ENOTCONN,
+ "errno is now set to ENOTCONN");
+
+ ok (mongo_sync_conn_get_slaveok (c) == FALSE,
+ "mongo_sync_get_slaveok() works");
+ cmp_ok (errno, "==", 0,
+ "errno is now cleared");
+
+ errno = 0;
+ mongo_sync_conn_set_slaveok (NULL, TRUE);
+ cmp_ok (errno, "==", ENOTCONN,
+ "errno is set to ENOTCONN after mongo_sync_conn_get_slaveok(NULL)");
+
+ mongo_sync_conn_set_slaveok (c, TRUE);
+ cmp_ok (errno, "==", 0,
+ "errno is cleared");
+ ok (mongo_sync_conn_get_slaveok (c) == TRUE,
+ "mongo_sync_set_slaveok() worked");
+
+ mongo_sync_disconnect (c);
+}
+
+RUN_TEST (7, mongo_sync_get_set_slaveok);