4
#include "libmongo-private.h"
7
test_mongo_sync_gridfs_stream_read (void)
9
mongo_sync_connection *conn;
10
mongo_sync_gridfs *gfs;
11
mongo_sync_gridfs_stream *stream;
14
mongo_util_oid_init (0);
16
ok (mongo_sync_gridfs_stream_read (NULL, buffer, sizeof (buffer)) == -1,
17
"mongo_sync_gridfs_stream_read() should fail with a NULL connection");
19
begin_network_tests (3);
21
conn = mongo_sync_connect (config.primary_host, config.primary_port, FALSE);
22
gfs = mongo_sync_gridfs_new (conn, config.gfs_prefix);
24
stream = mongo_sync_gridfs_stream_new (gfs, NULL);
26
ok (mongo_sync_gridfs_stream_read (stream, buffer, sizeof (buffer)) == -1,
27
"mongo-sync_gridfs_stream_read() should fail when the stream is "
30
stream->file.type = LMC_GRIDFS_FILE_STREAM_READER;
32
ok (mongo_sync_gridfs_stream_read (stream, NULL, sizeof (buffer)) == -1,
33
"mongo_sync_gridfs_stream_read() should fail with a NULL buffer");
34
ok (mongo_sync_gridfs_stream_read (stream, buffer, 0) == -1,
35
"mongo_sync_gridfs_stream_read() should fail with a 0 size");
37
mongo_sync_gridfs_stream_close (stream);
39
mongo_sync_gridfs_free (gfs, TRUE);
44
RUN_TEST (4, mongo_sync_gridfs_stream_read);