diff options
author | Randolph Tan <randolph@10gen.com> | 2012-12-03 13:18:14 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2012-12-05 09:55:33 -0500 |
commit | 33d7543c12a21f6496081ca9fa6c3676190aa991 (patch) | |
tree | 038aa3e2a8e0420a2c2c9b448d3e5771e0f1734d /src/mongo/dbtests/mock/mock_remote_db_server.cpp | |
parent | 0bdbde18449b907068a96bd02b4268febf78f6b1 (diff) | |
download | mongo-33d7543c12a21f6496081ca9fa6c3676190aa991.tar.gz |
SERVER-6754 Create a mock for testing replica set connections
Step2: Created a simple mock for cursor that matches the DBClientBase::query signature, added functionality for mocking queries and added more features.
Diffstat (limited to 'src/mongo/dbtests/mock/mock_remote_db_server.cpp')
-rw-r--r-- | src/mongo/dbtests/mock/mock_remote_db_server.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mongo/dbtests/mock/mock_remote_db_server.cpp b/src/mongo/dbtests/mock/mock_remote_db_server.cpp index b4296515bf8..8f4fb0953c8 100644 --- a/src/mongo/dbtests/mock/mock_remote_db_server.cpp +++ b/src/mongo/dbtests/mock/mock_remote_db_server.cpp @@ -106,6 +106,11 @@ namespace mongo_test { _cmdMap[cmdName].reset(new CircularBSONIterator(replySequence)); } + void MockRemoteDBServer::setQueryReply(const mongo::BSONArray& resultSet) { + scoped_spinlock sLock(_lock); + _queryReply = mongo::BSONArray(resultSet.copy()); + } + bool MockRemoteDBServer::runCommand(MockRemoteDBServer::InstanceID id, const string& dbname, const BSONObj& cmdObj, @@ -147,7 +152,7 @@ namespace mongo_test { return info["ok"].trueValue(); } - std::auto_ptr<mongo::DBClientCursor> MockRemoteDBServer::query( + mongo::BSONArray MockRemoteDBServer::query( MockRemoteDBServer::InstanceID id, const string& ns, mongo::Query query, @@ -164,11 +169,9 @@ namespace mongo_test { checkIfUp(id); - std::auto_ptr<mongo::DBClientCursor> cursor; - scoped_spinlock sLock(_lock); _queryCount++; - return cursor; + return _queryReply; } mongo::ConnectionString::ConnectionType MockRemoteDBServer::type() const { |