diff options
author | Matthew Russotto <matthew.russotto@10gen.com> | 2018-08-23 17:04:14 -0400 |
---|---|---|
committer | Matthew Russotto <matthew.russotto@10gen.com> | 2018-08-23 17:04:14 -0400 |
commit | e7afdfb2941808f078cae1aafa05e40bdb079766 (patch) | |
tree | 350e0b035f6b145d094419e0a63bd67b91c391e3 /src/mongo/dbtests/querytests.cpp | |
parent | 84cabb97f967774645dcb9ea2581e3345a9b7547 (diff) | |
download | mongo-e7afdfb2941808f078cae1aafa05e40bdb079766.tar.gz |
SERVER-36094 Make query by UUID work for DBClient.
Diffstat (limited to 'src/mongo/dbtests/querytests.cpp')
-rw-r--r-- | src/mongo/dbtests/querytests.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index 239ceae45ab..1193a26dd08 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -1668,6 +1668,35 @@ public: } }; +class QueryByUuid : public CollectionBase { +public: + QueryByUuid() : CollectionBase("QueryByUuid") {} + + void run() { + CollectionOptions coll_opts; + coll_opts.uuid = UUID::gen(); + { + Lock::GlobalWrite lk(&_opCtx); + OldClientContext context(&_opCtx, ns()); + WriteUnitOfWork wunit(&_opCtx); + context.db()->createCollection(&_opCtx, ns(), coll_opts, false); + wunit.commit(); + } + insert(ns(), BSON("a" << 1)); + insert(ns(), BSON("a" << 2)); + insert(ns(), BSON("a" << 3)); + unique_ptr<DBClientCursor> cursor = + _client.query(NamespaceStringOrUUID("unittests", *coll_opts.uuid), BSONObj()); + ASSERT_EQUALS(string(ns()), cursor->getns()); + for (int i = 1; i <= 3; ++i) { + ASSERT(cursor->more()); + BSONObj obj(cursor->next()); + ASSERT_EQUALS(obj["a"].Int(), i); + } + ASSERT(!cursor->more()); + } +}; + class CollectionInternalBase : public CollectionBase { public: CollectionInternalBase(const char* nsLeaf) @@ -1833,6 +1862,7 @@ public: add<FindingStartPartiallyFull>(); add<FindingStartStale>(); add<WhatsMyUri>(); + add<QueryByUuid>(); add<Exhaust>(); add<QueryReadsAll>(); add<queryobjecttests::names1>(); |