diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-12-19 14:31:36 -0500 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-12-19 17:29:29 -0500 |
commit | b5a2cc0fec6ac30b1a0196da5feb41d85a8b76c3 (patch) | |
tree | 4147e3b4ffbfea86eec107e7d6a6d777bded033d /src/mongo/db/pipeline/document_source_facet_test.cpp | |
parent | bd9c109958c1721767f5432683706c62ec90fe30 (diff) | |
download | mongo-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.cpp | 20 |
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); } |