diff options
Diffstat (limited to 'src/mongo/db/ops/update_driver_test.cpp')
-rw-r--r-- | src/mongo/db/ops/update_driver_test.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/mongo/db/ops/update_driver_test.cpp b/src/mongo/db/ops/update_driver_test.cpp index 794ede90844..c7ef14b3e9f 100644 --- a/src/mongo/db/ops/update_driver_test.cpp +++ b/src/mongo/db/ops/update_driver_test.cpp @@ -181,7 +181,7 @@ public: return *_driverRepl; } - OperationContext* txn() { + OperationContext* opCtx() { return _opCtx.get(); } @@ -254,139 +254,139 @@ static void assertSameFields(const BSONObj& docA, const BSONObj& docB) { TEST_F(CreateFromQuery, BasicOp) { BSONObj query = fromjson("{a:1,b:2}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(query, doc().getObject()); } TEST_F(CreateFromQuery, BasicOpEq) { BSONObj query = fromjson("{a:{$eq:1}}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{a:1}"), doc().getObject()); } TEST_F(CreateFromQuery, BasicOpWithId) { BSONObj query = fromjson("{_id:1,a:1,b:2}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(query, doc().getObject()); } TEST_F(CreateFromQuery, BasicRepl) { BSONObj query = fromjson("{a:1,b:2}"); - ASSERT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{}"), doc().getObject()); } TEST_F(CreateFromQuery, BasicReplWithId) { BSONObj query = fromjson("{_id:1,a:1,b:2}"); - ASSERT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{_id:1}"), doc().getObject()); } TEST_F(CreateFromQuery, BasicReplWithIdEq) { BSONObj query = fromjson("{_id:{$eq:1},a:1,b:2}"); - ASSERT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{_id:1}"), doc().getObject()); } TEST_F(CreateFromQuery, NoRootIdOp) { BSONObj query = fromjson("{'_id.a':1,'_id.b':2}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{_id:{a:1,b:2}}"), doc().getObject()); } TEST_F(CreateFromQuery, NoRootIdRepl) { BSONObj query = fromjson("{'_id.a':1,'_id.b':2}"); - ASSERT_NOT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_NOT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); } TEST_F(CreateFromQuery, NestedSharedRootOp) { BSONObj query = fromjson("{'a.c':1,'a.b':{$eq:2}}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{a:{c:1,b:2}}"), doc().getObject()); } TEST_F(CreateFromQuery, OrQueryOp) { BSONObj query = fromjson("{$or:[{a:1}]}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{a:1}"), doc().getObject()); } TEST_F(CreateFromQuery, OrQueryIdRepl) { BSONObj query = fromjson("{$or:[{_id:1}]}"); - ASSERT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{_id:1}"), doc().getObject()); } TEST_F(CreateFromQuery, OrQueryNoExtractOps) { BSONObj query = fromjson("{$or:[{a:1}, {b:2}]}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(BSONObj(), doc().getObject()); } TEST_F(CreateFromQuery, OrQueryNoExtractIdRepl) { BSONObj query = fromjson("{$or:[{_id:1}, {_id:2}]}"); - ASSERT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(BSONObj(), doc().getObject()); } TEST_F(CreateFromQuery, AndQueryOp) { BSONObj query = fromjson("{$and:[{'a.c':1},{'a.b':{$eq:2}}]}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{a:{c:1,b:2}}"), doc().getObject()); } TEST_F(CreateFromQuery, AndQueryIdRepl) { BSONObj query = fromjson("{$and:[{_id:1},{a:{$eq:2}}]}"); - ASSERT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{_id:1}"), doc().getObject()); } TEST_F(CreateFromQuery, AllArrayOp) { BSONObj query = fromjson("{a:{$all:[1]}}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{a:1}"), doc().getObject()); } TEST_F(CreateFromQuery, AllArrayIdRepl) { BSONObj query = fromjson("{_id:{$all:[1]}, b:2}"); - ASSERT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(fromjson("{_id:1}"), doc().getObject()); } TEST_F(CreateFromQuery, ConflictFieldsFailOp) { BSONObj query = fromjson("{a:1,'a.b':1}"); - ASSERT_NOT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_NOT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); } TEST_F(CreateFromQuery, ConflictFieldsFailSameValueOp) { BSONObj query = fromjson("{a:{b:1},'a.b':1}"); - ASSERT_NOT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_NOT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); } TEST_F(CreateFromQuery, ConflictWithIdRepl) { BSONObj query = fromjson("{_id:1,'_id.a':1}"); - ASSERT_NOT_OK(driverRepl().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_NOT_OK(driverRepl().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); } TEST_F(CreateFromQuery, ConflictAndQueryOp) { BSONObj query = fromjson("{$and:[{a:{b:1}},{'a.b':{$eq:1}}]}"); - ASSERT_NOT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_NOT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); } TEST_F(CreateFromQuery, ConflictAllMultipleValsOp) { BSONObj query = fromjson("{a:{$all:[1, 2]}}"); - ASSERT_NOT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_NOT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); } TEST_F(CreateFromQuery, NoConflictOrQueryOp) { BSONObj query = fromjson("{$or:[{a:{b:1}},{'a.b':{$eq:1}}]}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(BSONObj(), doc().getObject()); } TEST_F(CreateFromQuery, ImmutableFieldsOp) { BSONObj query = fromjson("{$or:[{a:{b:1}},{'a.b':{$eq:1}}]}"); - ASSERT_OK(driverOps().populateDocumentWithQueryFields(txn(), query, NULL, doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields(opCtx(), query, NULL, doc())); assertSameFields(BSONObj(), doc().getObject()); } @@ -395,7 +395,7 @@ TEST_F(CreateFromQuery, ShardKeyRepl) { OwnedPointerVector<FieldRef> immutablePaths; immutablePaths.push_back(new FieldRef("a")); ASSERT_OK(driverRepl().populateDocumentWithQueryFields( - txn(), query, &immutablePaths.vector(), doc())); + opCtx(), query, &immutablePaths.vector(), doc())); assertSameFields(fromjson("{a:1}"), doc().getObject()); } @@ -405,7 +405,7 @@ TEST_F(CreateFromQuery, NestedShardKeyRepl) { immutablePaths.push_back(new FieldRef("a")); immutablePaths.push_back(new FieldRef("b.c")); ASSERT_OK(driverRepl().populateDocumentWithQueryFields( - txn(), query, &immutablePaths.vector(), doc())); + opCtx(), query, &immutablePaths.vector(), doc())); assertSameFields(fromjson("{a:1,b:{c:2}}"), doc().getObject()); } @@ -414,8 +414,8 @@ TEST_F(CreateFromQuery, NestedShardKeyOp) { OwnedPointerVector<FieldRef> immutablePaths; immutablePaths.push_back(new FieldRef("a")); immutablePaths.push_back(new FieldRef("b.c")); - ASSERT_OK( - driverOps().populateDocumentWithQueryFields(txn(), query, &immutablePaths.vector(), doc())); + ASSERT_OK(driverOps().populateDocumentWithQueryFields( + opCtx(), query, &immutablePaths.vector(), doc())); assertSameFields(fromjson("{a:1,b:{c:2},d:3}"), doc().getObject()); } @@ -425,7 +425,7 @@ TEST_F(CreateFromQuery, NotFullShardKeyRepl) { immutablePaths.push_back(new FieldRef("a")); immutablePaths.push_back(new FieldRef("b")); ASSERT_NOT_OK(driverRepl().populateDocumentWithQueryFields( - txn(), query, &immutablePaths.vector(), doc())); + opCtx(), query, &immutablePaths.vector(), doc())); } } // unnamed namespace |