Skip to content

Commit 052809b

Browse files
committed
CDRIVER-2060 localThreshold code cleanups
1 parent d1a6795 commit 052809b

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/mongoc/mongoc-uri.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,6 @@ mongoc_uri_get_local_threshold_option (const mongoc_uri_t *uri)
12281228
if ((options = mongoc_uri_get_options (uri)) &&
12291229
bson_iter_init_find_case (&iter, options, "localthresholdms") &&
12301230
BSON_ITER_HOLDS_INT32 (&iter)) {
1231-
12321231
retval = bson_iter_int32 (&iter);
12331232

12341233
if (retval < 0) {

tests/test-mongoc-uri.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -879,43 +879,46 @@ test_mongoc_uri_long_hostname (void)
879879
bson_free (host_and_port);
880880
bson_free (host);
881881
}
882+
883+
static void
882884
test_mongoc_uri_local_threshold_ms (void)
883885
{
884886
mongoc_uri_t *uri;
885887

886888
uri = mongoc_uri_new ("mongodb://localhost/");
887889

888890
/* localthresholdms isn't set, return the default */
889-
ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==,
890-
MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS);
891-
ASSERT (
891+
ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri),
892+
==,MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS);
893+
ASSERT (
892894
mongoc_uri_set_option_as_int32 (uri, "localthresholdms", 99));
893895
ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 99);
894896

895-
mongoc_uri_destroy(uri);
897+
mongoc_uri_destroy (uri);
896898

897899

898-
uri = mongoc_uri_new ("mongodb://localhost/?localthresholdms=0");
900+
uri = mongoc_uri_new (
901+
"mongodb://localhost/?localthresholdms=0");
899902

900903
ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 0);
901904
ASSERT (
902905
mongoc_uri_set_option_as_int32 (uri, "localthresholdms", 99));
903906
ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==, 99);
904907

905-
mongoc_uri_destroy(uri);
906-
908+
mongoc_uri_destroy (uri);
907909

908-
uri = mongoc_uri_new(
909-
"mongodb://localhost/?" MONGOC_URI_LOCALTHRESHOLDMS "=-1");
910+
uri = mongoc_uri_new ("mongodb://localhost/?localthresholdms=-1");
910911

911912
/* localthresholdms is invalid, return the default */
912913
capture_logs (true);
913-
ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri), ==,
914-
MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS);
914+
ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri),
915+
==,
916+
MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS);
915917
ASSERT_CAPTURED_LOG ("mongoc_uri_get_local_threshold_option",
916-
MONGOC_LOG_LEVEL_WARNING, "Invalid localThresholdMS: -1");
918+
MONGOC_LOG_LEVEL_WARNING,
919+
"Invalid localThresholdMS: -1");
917920

918-
mongoc_uri_destroy(uri);
921+
mongoc_uri_destroy (uri);
919922
}
920923

921924

@@ -932,5 +935,6 @@ test_uri_install (TestSuite *suite)
932935
TestSuite_Add (suite, "/Uri/functions", test_mongoc_uri_functions);
933936
TestSuite_Add (suite, "/Uri/compound_setters", test_mongoc_uri_compound_setters);
934937
TestSuite_Add (suite, "/Uri/long_hostname", test_mongoc_uri_long_hostname);
935-
TestSuite_Add (suite, "/Uri/local_threshold_ms", test_mongoc_uri_local_threshold_ms);
938+
TestSuite_Add (
939+
suite, "/Uri/local_threshold_ms", test_mongoc_uri_local_threshold_ms);
936940
}

0 commit comments

Comments
 (0)