summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_request_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/query_request_test.cpp')
-rw-r--r--src/mongo/db/query/query_request_test.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/query/query_request_test.cpp b/src/mongo/db/query/query_request_test.cpp
index 0834cd6e4c8..f64a5429faf 100644
--- a/src/mongo/db/query/query_request_test.cpp
+++ b/src/mongo/db/query/query_request_test.cpp
@@ -473,6 +473,7 @@ TEST(QueryRequestTest, ParseFromCommandAllNonOptionFields) {
"projection: {c: 1},"
"hint: {d: 1},"
"readConcern: {e: 1},"
+ "$queryOptions: {$readPreference: 'secondary'},"
"collation: {f: 1},"
"limit: 3,"
"skip: 5,"
@@ -494,6 +495,9 @@ TEST(QueryRequestTest, ParseFromCommandAllNonOptionFields) {
ASSERT_EQUALS(0, expectedHint.woCompare(qr->getHint()));
BSONObj expectedReadConcern = BSON("e" << 1);
ASSERT_EQUALS(0, expectedReadConcern.woCompare(qr->getReadConcern()));
+ BSONObj expectedUnwrappedReadPref = BSON("$readPreference"
+ << "secondary");
+ ASSERT_EQUALS(0, expectedUnwrappedReadPref.woCompare(qr->getUnwrappedReadPref()));
BSONObj expectedCollation = BSON("f" << 1);
ASSERT_EQUALS(0, expectedCollation.woCompare(qr->getCollation()));
ASSERT_EQUALS(3, *qr->getLimit());
@@ -589,6 +593,7 @@ TEST(QueryRequestTest, ParseFromCommandSkipWrongType) {
ASSERT_NOT_OK(result.getStatus());
}
+
TEST(QueryRequestTest, ParseFromCommandLimitWrongType) {
BSONObj cmdObj = fromjson(
"{find: 'testns',"
@@ -624,6 +629,17 @@ TEST(QueryRequestTest, ParseFromCommandCommentWrongType) {
ASSERT_NOT_OK(result.getStatus());
}
+TEST(QueryRequestTest, ParseFromCommandUnwrappedReadPrefWrongType) {
+ BSONObj cmdObj = fromjson(
+ "{find: 'testns',"
+ "filter: {a: 1},"
+ "$queryOptions: 1}");
+ const NamespaceString nss("test.testns");
+ bool isExplain = false;
+ auto result = QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain);
+ ASSERT_NOT_OK(result.getStatus());
+}
+
TEST(QueryRequestTest, ParseFromCommandMaxScanWrongType) {
BSONObj cmdObj = fromjson(
"{find: 'testns',"