summaryrefslogtreecommitdiff
path: root/src/mongo/idl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/idl')
-rw-r--r--src/mongo/idl/SConscript1
-rw-r--r--src/mongo/idl/config_option_no_init_test.idl44
-rw-r--r--src/mongo/idl/config_option_test.cpp17
-rw-r--r--src/mongo/idl/config_option_test.idl2
4 files changed, 63 insertions, 1 deletions
diff --git a/src/mongo/idl/SConscript b/src/mongo/idl/SConscript
index 81625467b21..f320ffdff3c 100644
--- a/src/mongo/idl/SConscript
+++ b/src/mongo/idl/SConscript
@@ -61,6 +61,7 @@ env.CppUnitTest(
target='idl_config_option_test',
source=[
'config_option_test.cpp',
+ env.Idlc('config_option_no_init_test.idl')[0],
env.Idlc('config_option_test.idl')[0],
],
LIBDEPS=[
diff --git a/src/mongo/idl/config_option_no_init_test.idl b/src/mongo/idl/config_option_no_init_test.idl
new file mode 100644
index 00000000000..5e922ed654c
--- /dev/null
+++ b/src/mongo/idl/config_option_no_init_test.idl
@@ -0,0 +1,44 @@
+# Copyright (C) 2018-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+global:
+ cpp_namespace: "mongo::test"
+ configs:
+ source: [ cli, ini, yaml ]
+ initializer:
+ register: addIDLTestConfigs
+ store: storeIDLTestConfigs
+
+configs:
+ "test.config.noInit.opt1":
+ description: "Basic option using explicit call register/store"
+ short_name: testConfigNoInitOpt1
+ arg_vartype: String
+ cpp_vartype: std::string
+ cpp_varname: gTestConfigNoInitOpt1
+
diff --git a/src/mongo/idl/config_option_test.cpp b/src/mongo/idl/config_option_test.cpp
index 640bf1b6ef3..9e94434da85 100644
--- a/src/mongo/idl/config_option_test.cpp
+++ b/src/mongo/idl/config_option_test.cpp
@@ -31,6 +31,7 @@
#include "mongo/platform/basic.h"
+#include "mongo/idl/config_option_no_init_test_gen.h"
#include "mongo/idl/config_option_test_gen.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/cmdline_utils/censor_cmdline_test.h"
@@ -614,6 +615,22 @@ TEST(ConfigOption, Opt17) {
ASSERT_OPTION_SET<std::int32_t>(okParse, "test.config.opt17", kTestConfigOpt17Minimum);
}
+TEST(ConfigOptionNoInit, Opt1) {
+ moe::OptionSection options("Options");
+ ASSERT_OK(addIDLTestConfigs(&options));
+
+ const std::vector<std::string> argv({
+ "mongod", "--testConfigNoInitOpt1", "Hello",
+ });
+ moe::Environment parsed;
+ ASSERT_OK(moe::OptionsParser().run(options, argv, {}, &parsed));
+ ASSERT_OK(parsed.validate());
+ ASSERT_OK(storeIDLTestConfigs(parsed));
+
+ ASSERT_OPTION_SET<std::string>(parsed, "test.config.noInit.opt1", "Hello");
+ ASSERT_EQ(gTestConfigNoInitOpt1, "Hello");
+}
+
} // namespace
} // namespace test
} // namespace mongo
diff --git a/src/mongo/idl/config_option_test.idl b/src/mongo/idl/config_option_test.idl
index d5eaf220195..325f5eec321 100644
--- a/src/mongo/idl/config_option_test.idl
+++ b/src/mongo/idl/config_option_test.idl
@@ -32,7 +32,7 @@ global:
- "mongo/idl/server_parameter_with_storage_test.h"
- "mongo/idl/config_option_test.h"
configs:
- initializer_name: TestConfigs
+ initializer: TestConfigs
configs:
"test.config.opt1":