summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_change_stream_test.cpp
diff options
context:
space:
mode:
authorNick Zolnierz <nicholas.zolnierz@mongodb.com>2018-03-20 17:30:14 -0400
committerNick Zolnierz <nicholas.zolnierz@mongodb.com>2018-04-04 14:42:00 -0400
commit527386807d3fc2897542e90539e3f5230922c865 (patch)
treeb12ccf54e0408d88e6f76319e50cdd5e5dd478ca /src/mongo/db/pipeline/document_source_change_stream_test.cpp
parentea14c46d8a5b8d33412ef2c62b09475fe8533976 (diff)
downloadmongo-527386807d3fc2897542e90539e3f5230922c865.tar.gz
SERVER-33818: Add 'resumeWithClusterTime' as an alias for '$_resumeAfterClusterTime' in $changeStream
Diffstat (limited to 'src/mongo/db/pipeline/document_source_change_stream_test.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_test.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_change_stream_test.cpp b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
index 3fc8a21ad02..2b7661d3f58 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_test.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
@@ -270,6 +270,43 @@ TEST_F(ChangeStreamStageTest, ShouldRejectBothResumeAfterClusterTimeAndResumeAft
40674);
}
+TEST_F(ChangeStreamStageTest, ShouldRejectBothStartAtClusterTimeAndResumeAfterOptions) {
+ auto expCtx = getExpCtx();
+
+ // Need to put the collection in the UUID catalog so the resume token is valid.
+ Collection collection(stdx::make_unique<CollectionMock>(nss));
+ UUIDCatalog::get(expCtx->opCtx).onCreateCollection(expCtx->opCtx, &collection, testUuid());
+
+ ASSERT_THROWS_CODE(
+ DSChangeStream::createFromBson(
+ BSON(DSChangeStream::kStageName << BSON(
+ "resumeAfter" << makeResumeToken(ts, testUuid(), BSON("x" << 2 << "_id" << 1))
+ << "startAtClusterTime"
+ << BSON("ts" << ts)))
+ .firstElement(),
+ expCtx),
+ AssertionException,
+ 40674);
+}
+
+TEST_F(ChangeStreamStageTest, ShouldRejectBothStartAtAndResumeAfterClusterTimeOptions) {
+ auto expCtx = getExpCtx();
+
+ // Need to put the collection in the UUID catalog so the resume token is valid.
+ Collection collection(stdx::make_unique<CollectionMock>(nss));
+ UUIDCatalog::get(expCtx->opCtx).onCreateCollection(expCtx->opCtx, &collection, testUuid());
+
+ ASSERT_THROWS_CODE(
+ DSChangeStream::createFromBson(
+ BSON(DSChangeStream::kStageName
+ << BSON("$_resumeAfterClusterTime" << BSON("ts" << ts) << "startAtClusterTime"
+ << BSON("ts" << ts)))
+ .firstElement(),
+ expCtx),
+ AssertionException,
+ 50573);
+}
+
TEST_F(ChangeStreamStageTestNoSetup, FailsWithNoReplicationCoordinator) {
const auto spec = fromjson("{$changeStream: {}}");