diff options
author | Mathias Stearn <mathias@10gen.com> | 2014-05-29 15:36:28 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2014-05-30 12:10:16 -0400 |
commit | a78d754b67040c19714bc4696dd7feb5ce10d412 (patch) | |
tree | aaf640483eff976ff22fdaceb9ebfa78f7659af2 /src/mongo/dbtests/counttests.cpp | |
parent | 4edbe14669b7804180d8b58549e257ceb679bb1d (diff) | |
download | mongo-a78d754b67040c19714bc4696dd7feb5ce10d412.tar.gz |
SERVER-13641 Plumb OperationContext through to getCollection and all Helpers
Diffstat (limited to 'src/mongo/dbtests/counttests.cpp')
-rw-r--r-- | src/mongo/dbtests/counttests.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/mongo/dbtests/counttests.cpp b/src/mongo/dbtests/counttests.cpp index 729443e2835..7ece0d6e0ee 100644 --- a/src/mongo/dbtests/counttests.cpp +++ b/src/mongo/dbtests/counttests.cpp @@ -41,18 +41,10 @@ namespace CountTests { class Base { - OperationContextImpl _txn; - Lock::DBWrite lk; - - Client::Context _context; - - Database* _database; - Collection* _collection; - public: Base() : lk(_txn.lockState(), ns()), _context( ns() ) { _database = _context.db(); - _collection = _database->getCollection( ns() ); + _collection = _database->getCollection( &_txn, ns() ); if ( _collection ) { _database->dropCollection( &_txn, ns() ); } @@ -100,6 +92,17 @@ namespace CountTests { static BSONObj countCommand( const BSONObj &query ) { return BSON( "query" << query ); } + + OperationContextImpl _txn; + + private: + Lock::DBWrite lk; + + Client::Context _context; + + Database* _database; + Collection* _collection; + }; class Basic : public Base { @@ -109,7 +112,7 @@ namespace CountTests { BSONObj cmd = fromjson( "{\"query\":{}}" ); string err; int errCode; - ASSERT_EQUALS( 1, runCount( ns(), cmd, err, errCode ) ); + ASSERT_EQUALS( 1, runCount( &_txn, ns(), cmd, err, errCode ) ); } }; @@ -122,7 +125,7 @@ namespace CountTests { BSONObj cmd = fromjson( "{\"query\":{\"a\":\"b\"}}" ); string err; int errCode; - ASSERT_EQUALS( 2, runCount( ns(), cmd, err, errCode ) ); + ASSERT_EQUALS( 2, runCount( &_txn, ns(), cmd, err, errCode ) ); } }; @@ -134,7 +137,7 @@ namespace CountTests { BSONObj cmd = fromjson( "{\"query\":{},\"fields\":{\"a\":1}}" ); string err; int errCode; - ASSERT_EQUALS( 2, runCount( ns(), cmd, err, errCode ) ); + ASSERT_EQUALS( 2, runCount( &_txn, ns(), cmd, err, errCode ) ); } }; @@ -147,7 +150,7 @@ namespace CountTests { BSONObj cmd = fromjson( "{\"query\":{\"a\":\"b\"},\"fields\":{\"a\":1}}" ); string err; int errCode; - ASSERT_EQUALS( 1, runCount( ns(), cmd, err, errCode ) ); + ASSERT_EQUALS( 1, runCount( &_txn, ns(), cmd, err, errCode ) ); } }; @@ -159,7 +162,7 @@ namespace CountTests { BSONObj cmd = fromjson( "{\"query\":{\"a\":/^b/}}" ); string err; int errCode; - ASSERT_EQUALS( 1, runCount( ns(), cmd, err, errCode ) ); + ASSERT_EQUALS( 1, runCount( &_txn, ns(), cmd, err, errCode ) ); } }; |