summaryrefslogtreecommitdiff
path: root/tests/unit/mongo/sync-gridfs/sync_gridfs_get_set_chunk_size.c
blob: 5d17986af177370a30577b28b41bc07fc3006c37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "test.h"
#include "mongo.h"

void
test_mongo_sync_gridfs_get_set_chunk_size (void)
{
  mongo_sync_gridfs *gfs;

  ok (mongo_sync_gridfs_get_chunk_size (NULL) == -1,
      "mongo_sync_gridfs_get_chunk_size() fails with a NULL gfs");
  ok (mongo_sync_gridfs_set_chunk_size (NULL, 16 * 1024) == FALSE,
      "mongo_sync_gridfs_set_chunk_size() fails with a NULL gfs");

  begin_network_tests (3);

  gfs = mongo_sync_gridfs_new (mongo_sync_connect (config.primary_host,
                                                   config.primary_port,
                                                   FALSE),
                               config.gfs_prefix);

  ok (mongo_sync_gridfs_set_chunk_size (gfs, -1) == FALSE,
      "mongo_sync_gridfs_set_chunk_size() fails if the size is invalid");
  ok (mongo_sync_gridfs_set_chunk_size (gfs, 12345),
      "mongo_sync_gridfs_set_chunk_size() works");
  cmp_ok (mongo_sync_gridfs_get_chunk_size (gfs), "==", 12345,
          "mongo_sync_gridfs_get_chunk_size() works");

  mongo_sync_gridfs_free (gfs, TRUE);

  end_network_tests ();
}

RUN_TEST (5, mongo_sync_gridfs_get_set_chunk_size);