summaryrefslogtreecommitdiff
path: root/tests/unit/mongo/sync-gridfs/sync_gridfs_free.c
blob: 1c8c2d61093ced5f72da07d93b30540f5e2ecbde (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
34
35
#include "test.h"
#include "mongo.h"

#include <errno.h>

void
test_mongo_sync_gridfs_free (void)
{
  mongo_sync_connection *conn;
  mongo_sync_gridfs *gfs;

  errno = 0;
  mongo_sync_gridfs_free (NULL, FALSE);
  cmp_ok (errno, "==", ENOTCONN,
          "mongo_sync_gridfs_free() with a NULL connection shall set errno");

  begin_network_tests (2);

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

  mongo_sync_gridfs_free (gfs, FALSE);
  cmp_ok (errno, "==", 0,
          "mongo_sync_gridfs_free() should clear errno on success");

  gfs = mongo_sync_gridfs_new (conn, config.gfs_prefix);
  mongo_sync_gridfs_free (gfs, TRUE);
  cmp_ok (errno, "==", 0,
          "mongo_sync_gridfs_free() works when asked to free the "
          "connection too");

  end_network_tests ();
}

RUN_TEST (3, mongo_sync_gridfs_free);