diff options
author | Waley Chen <waleycz@gmail.com> | 2016-05-17 14:05:13 -0400 |
---|---|---|
committer | Waley Chen <waleycz@gmail.com> | 2016-05-17 17:27:12 -0400 |
commit | 51ee6f1952addc650b1c719cce51fcf460e6e9e8 (patch) | |
tree | 426840377be5d2b698678f009f8328e57a89d40c /src/mongo/dbtests/query_stage_near.cpp | |
parent | 44abb8db32a6fad705854793e397961dfc72d09e (diff) | |
download | mongo-51ee6f1952addc650b1c719cce51fcf460e6e9e8.tar.gz |
SERVER-23243 Replace Listener::getElapsedTimeMillis() in scoped_timer.cpp
Diffstat (limited to 'src/mongo/dbtests/query_stage_near.cpp')
-rw-r--r-- | src/mongo/dbtests/query_stage_near.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/mongo/dbtests/query_stage_near.cpp b/src/mongo/dbtests/query_stage_near.cpp index 58833e6a2bf..d973779e7ed 100644 --- a/src/mongo/dbtests/query_stage_near.cpp +++ b/src/mongo/dbtests/query_stage_near.cpp @@ -34,6 +34,7 @@ #include "mongo/platform/basic.h" #include "mongo/base/owned_pointer_vector.h" +#include "mongo/db/client.h" #include "mongo/db/exec/near.h" #include "mongo/db/exec/queued_data_stage.h" #include "mongo/db/exec/working_set_common.h" @@ -48,6 +49,12 @@ using std::unique_ptr; using std::vector; using stdx::make_unique; +class QueryStageNearTest : public unittest::Test { +protected: + const ServiceContext::UniqueOperationContext _uniqOpCtx = cc().makeOperationContext(); + OperationContext* const _opCtx = _uniqOpCtx.get(); +}; + /** * Stage which implements a basic distance search, and interprets the "distance" field of * fetched documents as the distance. @@ -63,8 +70,9 @@ public: double max; }; - MockNearStage(WorkingSet* workingSet) - : NearStage(NULL, "MOCK_DISTANCE_SEARCH_STAGE", STAGE_UNKNOWN, workingSet, NULL), _pos(0) {} + MockNearStage(OperationContext* opCtx, WorkingSet* workingSet) + : NearStage(opCtx, "MOCK_DISTANCE_SEARCH_STAGE", STAGE_UNKNOWN, workingSet, NULL), + _pos(0) {} void addInterval(vector<BSONObj> data, double min, double max) { _intervals.mutableVector().push_back(new MockInterval(data, min, max)); @@ -139,11 +147,11 @@ static void assertAscendingAndValid(const vector<BSONObj>& results) { } } -TEST(query_stage_near, Basic) { +TEST_F(QueryStageNearTest, Basic) { vector<BSONObj> mockData; WorkingSet workingSet; - MockNearStage nearStage(&workingSet); + MockNearStage nearStage(_opCtx, &workingSet); // First set of results mockData.clear(); @@ -174,11 +182,11 @@ TEST(query_stage_near, Basic) { assertAscendingAndValid(results); } -TEST(query_stage_near, EmptyResults) { +TEST_F(QueryStageNearTest, EmptyResults) { vector<BSONObj> mockData; WorkingSet workingSet; - MockNearStage nearStage(&workingSet); + MockNearStage nearStage(_opCtx, &workingSet); // Empty set of results mockData.clear(); |