diff options
author | Daniel Solnik <dan.solnik@Daniels-MacBook-Pro-3.local> | 2019-06-07 13:04:20 -0400 |
---|---|---|
committer | Daniel Solnik <dansolnik@gmail.com> | 2019-06-26 14:06:12 -0400 |
commit | f16da96fdbb9a151cbc9890802c53370298b4fd2 (patch) | |
tree | 265a51f227be275dc2c5bf7449426fa85782cfa3 /src/mongo/dbtests | |
parent | d40952211bc71634435be37855855243154a3571 (diff) | |
download | mongo-f16da96fdbb9a151cbc9890802c53370298b4fd2.tar.gz |
SERVER-38796 Refactor CollectionOptions::parse to be static
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/querytests.cpp | 9 | ||||
-rw-r--r-- | src/mongo/dbtests/rollbacktests.cpp | 42 |
2 files changed, 26 insertions, 25 deletions
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index a41e2d9054b..2dca15f78b7 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -51,6 +51,7 @@ #include "mongo/db/query/find.h" #include "mongo/db/service_context.h" #include "mongo/dbtests/dbtests.h" +#include "mongo/unittest/unittest.h" #include "mongo/util/timer.h" namespace { @@ -1356,10 +1357,10 @@ public: // a bit. { WriteUnitOfWork wunit(&_opCtx); - CollectionOptions collectionOptions; - ASSERT_OK( - collectionOptions.parse(fromjson("{ capped : true, size : 2000, max: 10000 }"), - CollectionOptions::parseForCommand)); + + CollectionOptions collectionOptions = unittest::assertGet( + CollectionOptions::parse(fromjson("{ capped : true, size : 2000, max: 10000 }"), + CollectionOptions::parseForCommand)); NamespaceString nss(ns()); ASSERT(ctx.db()->userCreateNS(&_opCtx, nss, collectionOptions, false).isOK()); wunit.commit(); diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp index d7d1607c1c2..4dfcfee6c66 100644 --- a/src/mongo/dbtests/rollbacktests.cpp +++ b/src/mongo/dbtests/rollbacktests.cpp @@ -45,6 +45,7 @@ using std::unique_ptr; using std::list; using std::string; +using mongo::unittest::assertGet; namespace RollbackTests { @@ -73,9 +74,8 @@ void createCollection(OperationContext* opCtx, const NamespaceString& nss) { { WriteUnitOfWork uow(opCtx); ASSERT(!collectionExists(opCtx, &ctx, nss.ns())); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); - ASSERT_OK(ctx.db()->userCreateNS(opCtx, nss, collectionOptions, false)); + CollectionOptions defaultCollectionOptions; + ASSERT_OK(ctx.db()->userCreateNS(opCtx, nss, defaultCollectionOptions, false)); ASSERT(collectionExists(opCtx, &ctx, nss.ns())); uow.commit(); } @@ -175,8 +175,8 @@ public: WriteUnitOfWork uow(&opCtx); ASSERT(!collectionExists(&opCtx, &ctx, ns)); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(options, CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(options, CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); ASSERT(collectionExists(&opCtx, &ctx, ns)); if (!rollback) { @@ -212,8 +212,8 @@ public: WriteUnitOfWork uow(&opCtx); ASSERT(!collectionExists(&opCtx, &ctx, ns)); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(options, CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(options, CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); uow.commit(); } @@ -263,8 +263,8 @@ public: ASSERT(!collectionExists(&opCtx, &ctx, source.ns())); ASSERT(!collectionExists(&opCtx, &ctx, target.ns())); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(options, CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(options, CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, source, collectionOptions, defaultIndexes)); uow.commit(); } @@ -322,8 +322,8 @@ public: ASSERT(!collectionExists(&opCtx, &ctx, source.ns())); ASSERT(!collectionExists(&opCtx, &ctx, target.ns())); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(options, CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(options, CollectionOptions::parseForCommand)); auto db = ctx.db(); ASSERT_OK(db->userCreateNS(&opCtx, source, collectionOptions, defaultIndexes)); ASSERT_OK(db->userCreateNS(&opCtx, target, collectionOptions, defaultIndexes)); @@ -390,8 +390,8 @@ public: { WriteUnitOfWork uow(&opCtx); ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); insertRecord(&opCtx, nss, oldDoc); uow.commit(); @@ -411,8 +411,8 @@ public: {}, DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); insertRecord(&opCtx, nss, newDoc); @@ -449,8 +449,8 @@ public: { WriteUnitOfWork uow(&opCtx); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); insertRecord(&opCtx, nss, doc); @@ -492,8 +492,8 @@ public: { WriteUnitOfWork uow(&opCtx); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); insertRecord(&opCtx, nss, doc); @@ -690,8 +690,8 @@ public: { WriteUnitOfWork uow(&opCtx); ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); - CollectionOptions collectionOptions; - ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); + CollectionOptions collectionOptions = + assertGet(CollectionOptions::parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, false)); ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); Collection* coll = ctx.db()->getCollection(&opCtx, nss); |