summaryrefslogtreecommitdiff
path: root/src/mongo/embedded/mongo_embedded
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
commit959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch)
treeacc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/embedded/mongo_embedded
parent76588293975fc059cf076779e4283e6ffaf8afff (diff)
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/embedded/mongo_embedded')
-rw-r--r--src/mongo/embedded/mongo_embedded/SConscript1
-rw-r--r--src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp21
2 files changed, 12 insertions, 10 deletions
diff --git a/src/mongo/embedded/mongo_embedded/SConscript b/src/mongo/embedded/mongo_embedded/SConscript
index 8f84ee065d5..7a5f2043d6b 100644
--- a/src/mongo/embedded/mongo_embedded/SConscript
+++ b/src/mongo/embedded/mongo_embedded/SConscript
@@ -94,6 +94,7 @@ if get_option('link-model') != 'dynamic-sdk':
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
+ '$BUILD_DIR/mongo/bson/bson_validate',
'$BUILD_DIR/mongo/db/commands/test_commands_enabled',
'$BUILD_DIR/mongo/db/server_options_core',
'$BUILD_DIR/mongo/rpc/message',
diff --git a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
index 0e5c1a9dadf..4a9945875f9 100644
--- a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
+++ b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
@@ -35,6 +35,7 @@
#include <yaml-cpp/yaml.h>
#include "mongo/base/initializer.h"
+#include "mongo/bson/bson_validate.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/json.h"
@@ -194,7 +195,7 @@ protected:
// convert the message into an OpMessage to examine its BSON
auto outputOpMsg = mongo::OpMsg::parseOwned(outputMessage);
- ASSERT(outputOpMsg.body.valid());
+ ASSERT_OK(mongo::validateBSON(outputOpMsg.body));
return outputOpMsg.body;
}
@@ -407,7 +408,7 @@ TEST_F(MongodbCAPITest, ReadDB) {
auto outputBSON = performRpc(client, findMsg);
- ASSERT(outputBSON.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON));
ASSERT(outputBSON.hasField("cursor"));
ASSERT(outputBSON.getField("cursor").embeddedObject().hasField("firstBatch"));
mongo::BSONObj arrObj =
@@ -432,7 +433,7 @@ TEST_F(MongodbCAPITest, InsertAndRead) {
"{insert: 'collection_name', documents: [{firstName: 'Mongo', lastName: 'DB', age: 10}]}");
auto insertOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", insertObj);
auto outputBSON1 = performRpc(client, insertOpMsg);
- ASSERT(outputBSON1.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON1));
ASSERT(outputBSON1.hasField("n"));
ASSERT(outputBSON1.getIntField("n") == 1);
ASSERT(outputBSON1.hasField("ok"));
@@ -441,7 +442,7 @@ TEST_F(MongodbCAPITest, InsertAndRead) {
mongo::BSONObj findObj = mongo::fromjson("{find: 'collection_name', limit: 1}");
auto findMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", findObj);
auto outputBSON2 = performRpc(client, findMsg);
- ASSERT(outputBSON2.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON2));
ASSERT(outputBSON2.hasField("cursor"));
ASSERT(outputBSON2.getField("cursor").embeddedObject().hasField("firstBatch"));
mongo::BSONObj arrObj =
@@ -467,7 +468,7 @@ TEST_F(MongodbCAPITest, InsertAndReadDifferentClients) {
"{insert: 'collection_name', documents: [{firstName: 'Mongo', lastName: 'DB', age: 10}]}");
auto insertOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", insertObj);
auto outputBSON1 = performRpc(client1, insertOpMsg);
- ASSERT(outputBSON1.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON1));
ASSERT(outputBSON1.hasField("n"));
ASSERT(outputBSON1.getIntField("n") == 1);
ASSERT(outputBSON1.hasField("ok"));
@@ -476,7 +477,7 @@ TEST_F(MongodbCAPITest, InsertAndReadDifferentClients) {
mongo::BSONObj findObj = mongo::fromjson("{find: 'collection_name', limit: 1}");
auto findMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", findObj);
auto outputBSON2 = performRpc(client2, findMsg);
- ASSERT(outputBSON2.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON2));
ASSERT(outputBSON2.hasField("cursor"));
ASSERT(outputBSON2.getField("cursor").embeddedObject().hasField("firstBatch"));
mongo::BSONObj arrObj =
@@ -501,7 +502,7 @@ TEST_F(MongodbCAPITest, InsertAndDelete) {
"age: 10}]}");
auto insertOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", insertObj);
auto outputBSON1 = performRpc(client, insertOpMsg);
- ASSERT(outputBSON1.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON1));
ASSERT(outputBSON1.hasField("n"));
ASSERT(outputBSON1.getIntField("n") == 1);
ASSERT(outputBSON1.hasField("ok"));
@@ -514,7 +515,7 @@ TEST_F(MongodbCAPITest, InsertAndDelete) {
"1}]}");
auto deleteOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", deleteObj);
auto outputBSON2 = performRpc(client, deleteOpMsg);
- ASSERT(outputBSON2.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON2));
ASSERT(outputBSON2.hasField("n"));
ASSERT(outputBSON2.getIntField("n") == 1);
ASSERT(outputBSON2.hasField("ok"));
@@ -530,7 +531,7 @@ TEST_F(MongodbCAPITest, InsertAndUpdate) {
"age: 10}]}");
auto insertOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", insertObj);
auto outputBSON1 = performRpc(client, insertOpMsg);
- ASSERT(outputBSON1.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON1));
ASSERT(outputBSON1.hasField("n"));
ASSERT(outputBSON1.getIntField("n") == 1);
ASSERT(outputBSON1.hasField("ok"));
@@ -543,7 +544,7 @@ TEST_F(MongodbCAPITest, InsertAndUpdate) {
"{age: 5}}}]}");
auto updateOpMsg = mongo::OpMsgRequest::fromDBAndBody("db_name", updateObj);
auto outputBSON2 = performRpc(client, updateOpMsg);
- ASSERT(outputBSON2.valid());
+ ASSERT_OK(mongo::validateBSON(outputBSON2));
ASSERT(outputBSON2.hasField("ok"));
ASSERT(outputBSON2.getField("ok").numberDouble() == 1.0);
ASSERT(outputBSON2.hasField("nModified"));