summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_facet_test.cpp
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2017-12-19 14:31:36 -0500
committerCharlie Swanson <charlie.swanson@mongodb.com>2017-12-19 17:29:29 -0500
commitb5a2cc0fec6ac30b1a0196da5feb41d85a8b76c3 (patch)
tree4147e3b4ffbfea86eec107e7d6a6d777bded033d /src/mongo/db/pipeline/document_source_facet_test.cpp
parentbd9c109958c1721767f5432683706c62ec90fe30 (diff)
downloadmongo-b5a2cc0fec6ac30b1a0196da5feb41d85a8b76c3.tar.gz
SERVER-32190 Make MongoProcessInterface always available
Diffstat (limited to 'src/mongo/db/pipeline/document_source_facet_test.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_facet_test.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/document_source_facet_test.cpp b/src/mongo/db/pipeline/document_source_facet_test.cpp
index 1ed1f4a779c..c706a5ca31e 100644
--- a/src/mongo/db/pipeline/document_source_facet_test.cpp
+++ b/src/mongo/db/pipeline/document_source_facet_test.cpp
@@ -463,8 +463,22 @@ TEST_F(DocumentSourceFacetTest, ShouldOptimizeInnerPipelines) {
ASSERT_TRUE(dummy->isOptimized);
}
-TEST_F(DocumentSourceFacetTest, ShouldPropogateDetachingAndReattachingOfOpCtx) {
+/**
+ * An implementation of the MongoProcessInterface that is okay with changing the OperationContext,
+ * but has no other parts of the interface implemented.
+ */
+class StubMongoProcessOkWithOpCtxChanges : public StubMongoProcessInterface {
+public:
+ void setOperationContext(OperationContext* opCtx) final {
+ return;
+ }
+};
+
+TEST_F(DocumentSourceFacetTest, ShouldPropagateDetachingAndReattachingOfOpCtx) {
auto ctx = getExpCtx();
+ // We're going to be changing the OperationContext, so we need to use a MongoProcessInterface
+ // that won't throw when we do so.
+ ctx->mongoProcessInterface = stdx::make_unique<StubMongoProcessOkWithOpCtxChanges>();
auto firstDummy = DocumentSourcePassthrough::create();
auto firstPipeline = unittest::assertGet(Pipeline::createFacetPipeline({firstDummy}, ctx));
@@ -480,12 +494,12 @@ TEST_F(DocumentSourceFacetTest, ShouldPropogateDetachingAndReattachingOfOpCtx) {
// Test detaching.
ASSERT_FALSE(firstDummy->isDetachedFromOpCtx);
ASSERT_FALSE(secondDummy->isDetachedFromOpCtx);
- facetStage->doDetachFromOperationContext();
+ facetStage->detachFromOperationContext();
ASSERT_TRUE(firstDummy->isDetachedFromOpCtx);
ASSERT_TRUE(secondDummy->isDetachedFromOpCtx);
// Test reattaching.
- facetStage->doReattachToOperationContext(ctx->opCtx);
+ facetStage->reattachToOperationContext(ctx->opCtx);
ASSERT_FALSE(firstDummy->isDetachedFromOpCtx);
ASSERT_FALSE(secondDummy->isDetachedFromOpCtx);
}