TEST(ExclusionProjectionExecutionTest, ShouldAlwaysKeepMetadataFromOriginalDoc) { ParsedExclusionProjection exclusion; exclusion.parse(BSON("a" << false)); MutableDocument inputDocBuilder(Document{{"_id", "ID"}, {"a", 1}}); inputDocBuilder.setRandMetaField(1.0); inputDocBuilder.setTextScore(10.0); Document inputDoc = inputDocBuilder.freeze(); auto result = exclusion.applyProjection(inputDoc); MutableDocument expectedDoc(Document{{"_id", "ID"}}); expectedDoc.copyMetaDataFrom(inputDoc); ASSERT_EQ(result, expectedDoc.freeze()); }
TEST(InclusionProjectionExecutionTest, ShouldAlwaysKeepMetadataFromOriginalDoc) { auto inclusion = makeInclusionProjectionWithDefaultPolicies(); inclusion.parse(BSON("a" << true)); MutableDocument inputDocBuilder(Document{{"a", 1}}); inputDocBuilder.setRandMetaField(1.0); inputDocBuilder.setTextScore(10.0); Document inputDoc = inputDocBuilder.freeze(); auto result = inclusion.applyProjection(inputDoc); MutableDocument expectedDoc(inputDoc); expectedDoc.copyMetaDataFrom(inputDoc); ASSERT_DOCUMENT_EQ(result, expectedDoc.freeze()); }