Skip to content

Commit 6f44f72

Browse files
committed
support string w URI option in test runner
To support `w=majority`
1 parent 43d3e65 commit 6f44f72

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/libmongoc/tests/unified/entity-map.c

+16-1
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,23 @@ uri_apply_options (mongoc_uri_t *uri, bson_t *opts, bson_error_t *error)
8787
mongoc_uri_set_read_concern (uri, rc);
8888
mongoc_read_concern_destroy (rc);
8989
} else if (0 == strcmp ("w", key)) {
90+
if (BSON_ITER_HOLDS_UTF8 (&iter)) {
91+
// Write concern may be string "majority".
92+
const char *w = bson_iter_utf8 (&iter, NULL);
93+
if (0 == strcmp (w, "majority")) {
94+
mongoc_write_concern_set_w (wc, MONGOC_WRITE_CONCERN_W_MAJORITY);
95+
} else {
96+
test_set_error (error, "Unrecognized string value for 'w' URI option: %s", w);
97+
}
98+
} else if (BSON_ITER_HOLDS_INT32 (&iter)) {
99+
mongoc_write_concern_set_w (wc, bson_iter_int32 (&iter));
100+
} else {
101+
test_set_error (error,
102+
"Expected int32 or string for 'w' URI option, got: %s",
103+
_mongoc_bson_type_to_str (bson_iter_type (&iter)));
104+
}
105+
90106
wcSet = true;
91-
mongoc_write_concern_set_w (wc, bson_iter_int32 (&iter));
92107
} else if (mongoc_uri_option_is_int32 (key)) {
93108
mongoc_uri_set_option_as_int32 (uri, key, bson_iter_int32 (&iter));
94109
} else if (mongoc_uri_option_is_int64 (key)) {

0 commit comments

Comments
 (0)