summaryrefslogtreecommitdiff
path: root/src/mongo/idl/idl_test.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2019-03-18 14:26:23 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2019-03-18 18:15:56 -0400
commitd9952e5baca401fd1b8f375016cd26b156f06e1a (patch)
treed122b6ab9a4f348a0226654ac3e93226b2f3e967 /src/mongo/idl/idl_test.cpp
parentc8120ddaf8a8bd9da9c8095165a4df485d5a58c9 (diff)
downloadmongo-d9952e5baca401fd1b8f375016cd26b156f06e1a.tar.gz
SERVER-40115 Generated serialization methods for commands which 'concatenate_with_db' do not append the $db field
Diffstat (limited to 'src/mongo/idl/idl_test.cpp')
-rw-r--r--src/mongo/idl/idl_test.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/mongo/idl/idl_test.cpp b/src/mongo/idl/idl_test.cpp
index 8bf0019af8e..bb45122060f 100644
--- a/src/mongo/idl/idl_test.cpp
+++ b/src/mongo/idl/idl_test.cpp
@@ -2384,20 +2384,37 @@ TEST(IDLCommand, TestKnownFieldDuplicate) {
ASSERT_EQUALS(28, testStruct.getField1());
ASSERT_EQUALS(42, testStruct.getMaxTimeMS());
- auto expectedDoc = BSON("KnownFieldCommand"
- << "coll1"
+ // OpMsg request serializes original '$db' out because it is part of the OP_MSG request
+ auto expectedOpMsgDoc = BSON("KnownFieldCommand"
+ << "coll1"
- << "field1"
- << 28
- << "maxTimeMS"
- << 42
- << "$db"
- << "db"
+ << "field1"
+ << 28
+ << "maxTimeMS"
+ << 42
+ << "$db"
+ << "db"
- << "$client"
- << "foo");
+ << "$client"
+ << "foo");
+
+ ASSERT_BSONOBJ_EQ(expectedOpMsgDoc, testStruct.serialize(testPassthrough).body);
+
+ // BSON serialize does not round-trip '$db' because it can passed in passthrough data
+ auto expectedBSONDoc = BSON("KnownFieldCommand"
+ << "coll1"
+
+ << "field1"
+ << 28
+ << "maxTimeMS"
+ << 42
+ << "$db"
+ << "foo"
+
+ << "$client"
+ << "foo");
- ASSERT_BSONOBJ_EQ(expectedDoc, testStruct.serialize(testPassthrough).body);
+ ASSERT_BSONOBJ_EQ(expectedBSONDoc, testStruct.toBSON(testPassthrough));
}