summaryrefslogtreecommitdiff
path: root/src/mongo/rpc/metadata_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/rpc/metadata_test.cpp')
-rw-r--r--src/mongo/rpc/metadata_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/rpc/metadata_test.cpp b/src/mongo/rpc/metadata_test.cpp
index d35a37d1b8d..898b98c745a 100644
--- a/src/mongo/rpc/metadata_test.cpp
+++ b/src/mongo/rpc/metadata_test.cpp
@@ -149,6 +149,19 @@ TEST(Metadata, UpconvertInvalidMetadata) {
AssertionException);
}
+TEST(Metadata, UpconvertDuplicateReadPreference) {
+ auto secondaryReadPref = BSON("mode"
+ << "secondary");
+ auto nearestReadPref = BSON("mode"
+ << "nearest");
+
+ BSONObjBuilder bob;
+ bob.append("query", BSON("$readPreference" << secondaryReadPref));
+ bob.append("$readPreference", nearestReadPref);
+
+ ASSERT_THROWS_CODE(
+ rpc::upconvertRequest("db", bob.obj(), 0), AssertionException, ErrorCodes::InvalidOptions);
+}
TEST(Metadata, UpconvertUsesDocumentSequecesCorrectly) {
// These are cases where it is valid to use document sequences.