summaryrefslogtreecommitdiff
path: root/src/mongo/db/server_options_test.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2016-03-22 15:28:08 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2016-03-22 15:28:08 -0400
commitb766d1a46bacf5ff94c585543e0e6538da559633 (patch)
treeadbaa86d4b308489116923c15e8ca41af91c5f9b /src/mongo/db/server_options_test.cpp
parent866a3747dcd895ef932c79fe250f5967f3366034 (diff)
downloadmongo-b766d1a46bacf5ff94c585543e0e6538da559633.tar.gz
SERVER-22525 Translate old-style implicit options into new-style
Diffstat (limited to 'src/mongo/db/server_options_test.cpp')
-rw-r--r--src/mongo/db/server_options_test.cpp66
1 files changed, 62 insertions, 4 deletions
diff --git a/src/mongo/db/server_options_test.cpp b/src/mongo/db/server_options_test.cpp
index fb2d3e3fa52..ce3ab0d0f55 100644
--- a/src/mongo/db/server_options_test.cpp
+++ b/src/mongo/db/server_options_test.cpp
@@ -144,7 +144,7 @@ TEST(Verbosity, CommandLineString) {
::mongo::logger::LogSeverity::Debug(verbosity));
}
-TEST(Verbosity, CommandLineEmptyString) {
+TEST(Verbosity, CommandLineStringDisguisedLongForm) {
OptionsParserTester parser;
moe::Environment environment;
moe::OptionSection options;
@@ -157,8 +157,8 @@ TEST(Verbosity, CommandLineEmptyString) {
std::vector<std::string> argv;
argv.push_back("binaryname");
- argv.push_back("--verbose");
- argv.push_back("");
+ argv.push_back("-verbose");
+ argv.push_back("vvvv");
std::map<std::string, std::string> env_map;
ASSERT_OK(parser.run(options, argv, env_map, &environment));
@@ -167,11 +167,31 @@ TEST(Verbosity, CommandLineEmptyString) {
ASSERT_OK(::mongo::canonicalizeServerOptions(&environment));
ASSERT_OK(::mongo::storeServerOptions(environment, argv));
- int verbosity = 0;
+ int verbosity = 4;
ASSERT_EQUALS(::mongo::logger::globalLogDomain()->getMinimumLogSeverity(),
::mongo::logger::LogSeverity::Debug(verbosity));
}
+TEST(Verbosity, CommandLineEmptyString) {
+ OptionsParserTester parser;
+ moe::Environment environment;
+ moe::OptionSection options;
+
+ // Reset the log level before we test
+ ::mongo::logger::globalLogDomain()->setMinimumLoggedSeverity(
+ ::mongo::logger::LogSeverity::Info());
+
+ ASSERT_OK(::mongo::addGeneralServerOptions(&options));
+
+ std::vector<std::string> argv;
+ argv.push_back("binaryname");
+ argv.push_back("--verbose");
+ argv.push_back("");
+ std::map<std::string, std::string> env_map;
+
+ ASSERT_NOT_OK(parser.run(options, argv, env_map, &environment));
+}
+
TEST(Verbosity, CommandLineBadString) {
OptionsParserTester parser;
moe::Environment environment;
@@ -194,6 +214,44 @@ TEST(Verbosity, CommandLineBadString) {
ASSERT_NOT_OK(::mongo::validateServerOptions(environment));
}
+TEST(Verbosity, CommandLineBadStringOnlyDash) {
+ OptionsParserTester parser;
+ moe::Environment environment;
+ moe::OptionSection options;
+
+ // Reset the log level before we test
+ ::mongo::logger::globalLogDomain()->setMinimumLoggedSeverity(
+ ::mongo::logger::LogSeverity::Info());
+
+ ASSERT_OK(::mongo::addGeneralServerOptions(&options));
+
+ std::vector<std::string> argv;
+ argv.push_back("binaryname");
+ argv.push_back("-");
+ std::map<std::string, std::string> env_map;
+
+ ASSERT_NOT_OK(parser.run(options, argv, env_map, &environment));
+}
+
+TEST(Verbosity, CommandLineBadStringOnlyTwoDashes) {
+ OptionsParserTester parser;
+ moe::Environment environment;
+ moe::OptionSection options;
+
+ // Reset the log level before we test
+ ::mongo::logger::globalLogDomain()->setMinimumLoggedSeverity(
+ ::mongo::logger::LogSeverity::Info());
+
+ ASSERT_OK(::mongo::addGeneralServerOptions(&options));
+
+ std::vector<std::string> argv;
+ argv.push_back("binaryname");
+ argv.push_back("--");
+ std::map<std::string, std::string> env_map;
+
+ ASSERT_OK(parser.run(options, argv, env_map, &environment));
+}
+
TEST(Verbosity, INIConfigString) {
OptionsParserTester parser;
moe::Environment environment;