summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/map_reduce_parse_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/map_reduce_parse_test.cpp')
-rw-r--r--src/mongo/db/commands/map_reduce_parse_test.cpp340
1 files changed, 175 insertions, 165 deletions
diff --git a/src/mongo/db/commands/map_reduce_parse_test.cpp b/src/mongo/db/commands/map_reduce_parse_test.cpp
index fc7f7e1ae9d..f89040dbf2e 100644
--- a/src/mongo/db/commands/map_reduce_parse_test.cpp
+++ b/src/mongo/db/commands/map_reduce_parse_test.cpp
@@ -50,201 +50,211 @@ constexpr auto finalizeJavascript = "finalize!"_sd;
TEST(MapReduceParseTest, failedParse) {
auto ctx = IDLParserErrorContext("mapReduce");
// Missing fields.
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON(""
- << ""
- << "$db"
- << "db")),
- DBException);
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("mapReduce"
- << "foo"
- << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON(""
+ << ""
+ << "$db"
+ << "db")),
DBException);
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("map" << mapJavascript << "reduce" << reduceJavascript
- << "out" << BSON("inline" << 1) << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "foo"
+ << "$db"
+ << "db")),
DBException);
+ ASSERT_THROWS(
+ MapReduceCommandRequest::parse(ctx,
+ BSON("map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db")),
+ DBException);
// Extra fields.
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript
- << "out" << BSON("inline" << 1) << "alloy"
- << "chromium steel"
- << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << reduceJavascript << "out"
+ << BSON("inline" << 1) << "alloy"
+ << "chromium steel"
+ << "$db"
+ << "db")),
DBException);
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript
- << "out" << BSON("inline" << 1 << "notinline" << 0) << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(
+ ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
+ << BSON("inline" << 1 << "notinline" << 0) << "$db"
+ << "db")),
DBException);
}
TEST(MapReduceParseTest, failsToParseCodeWithScope) {
auto ctx = IDLParserErrorContext("mapReduce");
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce"
- << BSONCodeWScope("var x = 3", BSONObj()) << "out"
- << BSON("inline" << 1) << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << BSONCodeWScope("var x = 3", BSONObj())
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db")),
+ DBException);
+ ASSERT_THROWS(MapReduceCommandRequest::parse(
+ ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << BSONCodeWScope("var x = 3", BSONObj()) << "reduce"
+ << reduceJavascript << "out" << BSON("inline" << 1) << "$db"
+ << "db")),
DBException);
- ASSERT_THROWS(
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << BSONCodeWScope("var x = 3", BSONObj()) << "reduce"
- << reduceJavascript << "out" << BSON("inline" << 1) << "$db"
- << "db")),
- DBException);
}
TEST(MapReduceParseTest, parseOutputTypes) {
auto ctx = IDLParserErrorContext("mapReduce");
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("inline" << 1) << "$db"
- << "db"));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << "theSink"
- << "$db"
- << "db"));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("replace"
- << "theSink"
- << "db"
- << "myDb")
- << "$db"
- << "db"));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("merge"
- << "theSink")
- << "$db"
- << "db"));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "sharded" << true)
- << "$db"
- << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << "theSink"
+ << "$db"
+ << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << BSON("replace"
+ << "theSink"
+ << "db"
+ << "myDb")
+ << "$db"
+ << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << BSON("merge"
+ << "theSink")
+ << "$db"
+ << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "sharded" << true)
+ << "$db"
+ << "db"));
ASSERT(true);
}
TEST(MapReduceParseTest, parseAllOptionalFields) {
auto ctx = IDLParserErrorContext("mapReduce");
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("inline" << 1) << "query"
- << BSON("author"
- << "dave")
- << "sort" << BSON("bottlecaps" << 1) << "collation"
- << BSON("locale"
- << "zh@collation=pinyin")
- << "limit" << 86 << "finalize" << finalizeJavascript << "scope"
- << BSON("global" << initJavascript) << "verbose" << false
- << "bypassDocumentValidation" << true << "writeConcern"
- << BSON("w" << 1 << "j" << false << "wtimeout" << 1498) << "$db"
- << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "query"
+ << BSON("author"
+ << "dave")
+ << "sort" << BSON("bottlecaps" << 1) << "collation"
+ << BSON("locale"
+ << "zh@collation=pinyin")
+ << "limit" << 86 << "finalize" << finalizeJavascript
+ << "scope" << BSON("global" << initJavascript) << "verbose"
+ << false << "bypassDocumentValidation" << true
+ << "writeConcern"
+ << BSON("w" << 1 << "j" << false << "wtimeout" << 1498)
+ << "$db"
+ << "db"));
}
TEST(MapReduceParseTest, deprecatedOptions) {
auto ctx = IDLParserErrorContext("mapReduce");
// jsMode can be true or false
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("inline" << 1) << "$db"
- << "db"
- << "jsMode" << true));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("inline" << 1) << "$db"
- << "db"
- << "jsMode" << false));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db"
+ << "jsMode" << true));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db"
+ << "jsMode" << false));
// nonAtomic can be true but not false
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "nonAtomic" << true)
- << "$db"
- << "db"));
- ASSERT_THROWS(
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "nonAtomic" << false)
- << "$db"
- << "db")),
- DBException);
- ASSERT_THROWS(
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "nonAtomic" << false)
- << "$db"
- << "db")),
- DBException);
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "nonAtomic" << true)
+ << "$db"
+ << "db"));
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << reduceJavascript << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "nonAtomic" << false)
+ << "$db"
+ << "db")),
+ DBException);
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << reduceJavascript << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "nonAtomic" << false)
+ << "$db"
+ << "db")),
+ DBException);
// out.sharded cannot be false
- ASSERT_THROWS(
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "sharded" << false)
- << "$db"
- << "db")),
- DBException);
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << reduceJavascript << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "sharded" << false)
+ << "$db"
+ << "db")),
+ DBException);
}
} // namespace