summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/aggregation_request_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/aggregation_request_test.cpp')
-rw-r--r--src/mongo/db/pipeline/aggregation_request_test.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/aggregation_request_test.cpp b/src/mongo/db/pipeline/aggregation_request_test.cpp
index 359ee994f4b..6e624272737 100644
--- a/src/mongo/db/pipeline/aggregation_request_test.cpp
+++ b/src/mongo/db/pipeline/aggregation_request_test.cpp
@@ -61,7 +61,8 @@ TEST(AggregationRequestTest, ShouldParseAllKnownOptions) {
"needsMerge: true, mergeByPBRT: true, bypassDocumentValidation: true, collation: {locale: "
"'en_US'}, cursor: {batchSize: 10}, hint: {a: 1}, maxTimeMS: 100, readConcern: {level: "
"'linearizable'}, $queryOptions: {$readPreference: 'nearest'}, comment: 'agg_comment', "
- "exchange: {policy: 'roundrobin', consumers:NumberInt(2)}}");
+ "exchange: {policy: 'roundrobin', consumers:NumberInt(2)}, $_passthroughToShard: "
+ "{shard: 'foo'}}");
auto request = unittest::assertGet(AggregationRequest::parseFromBSON(nss, inputBson));
ASSERT_FALSE(request.getExplain());
ASSERT_TRUE(request.shouldAllowDiskUse());
@@ -512,6 +513,20 @@ TEST(AggregationRequestTest, ShouldRejectInvalidWriteConcern) {
fromjson("{pipeline: [{$match: {a: 'abc'}}], cursor: {}, writeConcern: 'invalid'}");
ASSERT_NOT_OK(AggregationRequest::parseFromBSON(nss, inputBson).getStatus());
}
+
+TEST(AggregationRequestTest, ShouldRejectInvalidPassthroughToShard) {
+ NamespaceString nss("a.collection");
+ const BSONObj inputBson =
+ fromjson("{pipeline: [{$changeStream: {}}], cursor: {}, passthroughToShard: {foo: 'f'}}");
+ ASSERT_NOT_OK(AggregationRequest::parseFromBSON(nss, inputBson).getStatus());
+ const BSONObj inputBson2 =
+ fromjson("{pipeline: [{$changeStream: {}}], cursor: {}, passthroughToShard: {shard: 5}}");
+ ASSERT_NOT_OK(AggregationRequest::parseFromBSON(nss, inputBson2).getStatus());
+ const BSONObj inputBson3 =
+ fromjson("{pipeline: [{$changeStream: {}}], cursor: {}, passthroughToShard: {}}");
+ ASSERT_NOT_OK(AggregationRequest::parseFromBSON(nss, inputBson3).getStatus());
+}
+
//
// Ignore fields parsed elsewhere.
//