summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_request_test.cpp
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2018-11-19 12:27:33 -0500
committerMatthew Russotto <matthew.russotto@10gen.com>2018-11-20 13:34:54 -0500
commit0248ed957eb3892aeccc34ba89e4b768ca296dfc (patch)
tree11bee03374e99770878ea234e9d76a20229bc972 /src/mongo/db/query/query_request_test.cpp
parent44b900ade107cf4358c30a23ef230c27b100067e (diff)
downloadmongo-0248ed957eb3892aeccc34ba89e4b768ca296dfc.tar.gz
SERVER-36068 Expose a user-accessible cursor option to avoid caching data from reads
Diffstat (limited to 'src/mongo/db/query/query_request_test.cpp')
-rw-r--r--src/mongo/db/query/query_request_test.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/mongo/db/query/query_request_test.cpp b/src/mongo/db/query/query_request_test.cpp
index 9a84abbc214..b16f3ddabe2 100644
--- a/src/mongo/db/query/query_request_test.cpp
+++ b/src/mongo/db/query/query_request_test.cpp
@@ -402,7 +402,8 @@ TEST(QueryRequestTest, ParseFromCommandAllFlagsTrue) {
"oplogReplay: true,"
"noCursorTimeout: true,"
"awaitData: true,"
- "allowPartialResults: true}");
+ "allowPartialResults: true,"
+ "readOnce: true}");
const NamespaceString nss("test.testns");
bool isExplain = false;
unique_ptr<QueryRequest> qr(
@@ -415,6 +416,16 @@ TEST(QueryRequestTest, ParseFromCommandAllFlagsTrue) {
ASSERT(qr->isNoCursorTimeout());
ASSERT(qr->isTailableAndAwaitData());
ASSERT(qr->isAllowPartialResults());
+ ASSERT(qr->isReadOnce());
+}
+
+TEST(QueryRequestTest, ParseFromCommandReadOnceDefaultsToFalse) {
+ BSONObj cmdObj = fromjson("{find: 'testns'}");
+ const NamespaceString nss("test.testns");
+ bool isExplain = false;
+ unique_ptr<QueryRequest> qr(
+ assertGet(QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain)));
+ ASSERT(!qr->isReadOnce());
}
TEST(QueryRequestTest, ParseFromCommandCommentWithValidMinMax) {
@@ -765,6 +776,16 @@ TEST(QueryRequestTest, ParseFromCommandCollationWrongType) {
auto result = QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain);
ASSERT_NOT_OK(result.getStatus());
}
+
+TEST(QueryRequestTest, ParseFromCommandReadOnceWrongType) {
+ BSONObj cmdObj = fromjson(
+ "{find: 'testns',"
+ "readOnce: 1}");
+ const NamespaceString nss("test.testns");
+ bool isExplain = false;
+ auto result = QueryRequest::makeFromFindCommand(nss, cmdObj, isExplain);
+ ASSERT_EQ(ErrorCodes::FailedToParse, result.getStatus());
+}
//
// Parsing errors where a field has the right type but a bad value.
//
@@ -1293,6 +1314,13 @@ TEST(QueryRequestTest, ConvertToAggregationWithCollationSucceeds) {
ASSERT_BSONOBJ_EQ(ar.getValue().getCollation(), BSON("f" << 1));
}
+TEST(QueryRequestTest, ConvertToAggregationWithReadOnceFails) {
+ QueryRequest qr(testns);
+ qr.setReadOnce(true);
+ const auto aggCmd = qr.asAggregationCommand();
+ ASSERT_EQ(ErrorCodes::InvalidPipelineOperator, aggCmd.getStatus().code());
+}
+
TEST(QueryRequestTest, ParseFromLegacyObjMetaOpComment) {
BSONObj queryObj = fromjson(
"{$query: {a: 1},"