Default min/maxWireVersion when non provided for mock server
@@ -499,10 +499,22 @@ mock_server_auto_ismaster (mock_server_t *server,
{
char *formatted_response_json;
va_list args;
+ bson_t *tmp;
+ bson_iter_t iter;
va_start (args, response_json);
formatted_response_json = bson_strdupv_printf (response_json, args);
va_end (args);
+ tmp = tmp_bson (formatted_response_json);
+
+ if (!bson_iter_init_find (&iter, tmp, "minWireVersion")) {
+ BSON_APPEND_INT32 (tmp, "minWireVersion", WIRE_VERSION_MIN);
+ }
+ if (!bson_iter_init_find (&iter, tmp, "maxWireVersion")) {
+ BSON_APPEND_INT32 (tmp, "maxWireVersion", WIRE_VERSION_OP_MSG - 1);
+ }
+ bson_free (formatted_response_json);
+ formatted_response_json = bson_as_json (tmp, 0);
return mock_server_autoresponds (
server, auto_ismaster, (void *) formatted_response_json, bson_free);
