File: sync_connect_cache.c

package info (click to toggle)
libmongo-client 0.1.8-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 1,440 kB
  • sloc: ansic: 14,980; makefile: 317; perl: 137; sh: 48
file content (42 lines) | stat: -rw-r--r-- 1,307 bytes parent folder | download | duplicates (4)
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
36
37
38
39
40
41
42
#include "test.h"
#include "mongo.h"

void
test_mongo_sync_conn_recovery_cache_connection (void)
{
  mongo_sync_conn_recovery_cache *cache;
  mongo_sync_connection *c = NULL;

  cache = mongo_sync_conn_recovery_cache_new ();

  ok (mongo_sync_connect_recovery_cache (cache, FALSE) == NULL,
      "mongo_sync_connect_recovery_cache() should fail when cache is empty");

  begin_network_tests (4);

  ok (mongo_sync_conn_recovery_cache_seed_add (cache,
                                               config.primary_host,
                                               config.primary_port) == TRUE,
      "mongo_sync_conn_recovery_cache_seed_add() works");

  ok ((c = mongo_sync_connect_recovery_cache (cache, FALSE)) != NULL,
      "mongo_sync_connect_recovery_cache() works");

  mongo_sync_disconnect (c);

  ok ((c = mongo_sync_connect_recovery_cache (cache, FALSE)) != NULL,
      "mongo_sync_connect_recovery_cache() works after disconnect");

  mongo_sync_disconnect (c);

  mongo_sync_conn_recovery_cache_discard (cache);

  ok (mongo_sync_connect_recovery_cache (cache, TRUE) == NULL,
      "mongo_sync_connect_recovery_cache() should fail when cache is discarded");

  mongo_sync_conn_recovery_cache_free (cache);

  end_network_tests ();
}

RUN_TEST (5, mongo_sync_conn_recovery_cache_connection);