summaryrefslogtreecommitdiff
path: root/tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_new.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-gridfs-stream/sync_gridfs_stream_new.c
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_new.c')
-rw-r--r--tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_new.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_new.c b/tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_new.c
new file mode 100644
index 0000000..75e4419
--- /dev/null
+++ b/tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_new.c
@@ -0,0 +1,43 @@
+#include "test.h"
+#include "mongo.h"
+
+void
+test_mongo_sync_gridfs_stream_new (void)
+{
+ mongo_sync_connection *conn;
+ mongo_sync_gridfs *gfs;
+ mongo_sync_gridfs_stream *stream;
+ bson *meta;
+
+ mongo_util_oid_init (0);
+
+ meta = bson_build (BSON_TYPE_STRING, "my-id", "sync_gridfs_stream_new", -1,
+ BSON_TYPE_NONE);
+ bson_finish (meta);
+
+ ok (mongo_sync_gridfs_stream_new (NULL, meta) == FALSE,
+ "mongo_sync_gridfs_stream_new() should fail with a NULL connection");
+
+ begin_network_tests (2);
+
+ conn = mongo_sync_connect (config.primary_host, config.primary_port, FALSE);
+ gfs = mongo_sync_gridfs_new (conn, config.gfs_prefix);
+
+ stream = mongo_sync_gridfs_stream_new (gfs, NULL);
+ ok (stream != NULL,
+ "mongo_sync_gridfs_stream_new() works with NULL metadata");
+ mongo_sync_gridfs_stream_close (stream);
+
+ stream = mongo_sync_gridfs_stream_new (gfs, meta);
+ ok (stream != NULL,
+ "mongo_sync_gridfs_stream_new() works with metadata");
+ mongo_sync_gridfs_stream_close (stream);
+
+ mongo_sync_gridfs_free (gfs, TRUE);
+
+ end_network_tests ();
+
+ bson_free (meta);
+}
+
+RUN_TEST (3, mongo_sync_gridfs_stream_new);