From fd841e416881cc0392e61ec312c1870f3a0004bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Tue, 2 Dec 2014 10:06:21 +0100 Subject: Initial import of libmongo-client version 0.1.8-2 --- .../sync-gridfs-stream/sync_gridfs_stream_close.c | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_close.c (limited to 'tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_close.c') diff --git a/tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_close.c b/tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_close.c new file mode 100644 index 0000000..3c8a7b3 --- /dev/null +++ b/tests/unit/mongo/sync-gridfs-stream/sync_gridfs_stream_close.c @@ -0,0 +1,41 @@ +#include "test.h" +#include "mongo.h" + +#include "libmongo-private.h" + +void +test_mongo_sync_gridfs_stream_close (void) +{ + mongo_sync_connection *conn; + mongo_sync_gridfs *gfs; + mongo_sync_gridfs_stream *stream; + + mongo_util_oid_init (0); + + ok (mongo_sync_gridfs_stream_close (NULL) == FALSE, + "mongo_sync_gridfs_stream_close() fails with a NULL stream"); + + begin_network_tests (3); + + 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 (mongo_sync_gridfs_stream_close (stream) == TRUE, + "mongo_sync_gridfs_stream_close() works with a write stream"); + + stream = mongo_sync_gridfs_stream_new (gfs, NULL); + stream->file.type = LMC_GRIDFS_FILE_CHUNKED; + ok (mongo_sync_gridfs_stream_close (stream) == FALSE, + "mongo_sync_gridfs_stream_close() should fail with a chunked file"); + + stream->file.type = LMC_GRIDFS_FILE_STREAM_READER; + ok (mongo_sync_gridfs_stream_close (stream) == TRUE, + "mongo_sync_gridfs_stream_close() works with a read stream"); + + mongo_sync_gridfs_free (gfs, TRUE); + + end_network_tests (); +} + +RUN_TEST (4, mongo_sync_gridfs_stream_close); -- cgit v1.2.3