mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
Rename function for clarity
This commit is contained in:
parent
8160c13458
commit
60d0bf2a9b
@ -45,7 +45,7 @@ Configuration::addConfigValue(string_view section, string_view name, string_view
|
||||
}
|
||||
|
||||
void
|
||||
Configuration::validate()
|
||||
Configuration::validateRequiredFields()
|
||||
{
|
||||
visitSections([&](const std::string& section, const DefinitionMap&) {
|
||||
visitDefinitions(section, [&](const std::string&, const ConfigDefinition_ptr& def) {
|
||||
|
@ -222,16 +222,11 @@ namespace llarp
|
||||
return derived->getValue();
|
||||
}
|
||||
|
||||
/// Validate the config, presumably called after parsing. This will throw an exception if the
|
||||
/// parsed values do not meet the provided definition.
|
||||
///
|
||||
/// Note that this will only handle a subset of errors that may occur. Specifically, this will
|
||||
/// handle errors about missing required fields, whereas errors about incorrect type,
|
||||
/// duplicates, etc. are handled during parsing.
|
||||
/// Validate that all required fields are present.
|
||||
///
|
||||
/// @throws std::invalid_argument if configuration constraints are not met
|
||||
void
|
||||
validate();
|
||||
validateRequiredFields();
|
||||
|
||||
/// Generate a config string from the current config definition, optionally using overridden
|
||||
/// values. The generated config will preserve insertion order of both sections and their
|
||||
|
@ -105,11 +105,11 @@ TEST_CASE("Configuration required test", "[config]")
|
||||
false,
|
||||
1));
|
||||
|
||||
CHECK_THROWS(config.validate());
|
||||
CHECK_THROWS(config.validateRequiredFields());
|
||||
|
||||
config.addConfigValue("router", "threads", "12");
|
||||
|
||||
CHECK_NOTHROW(config.validate());
|
||||
CHECK_NOTHROW(config.validateRequiredFields());
|
||||
}
|
||||
|
||||
TEST_CASE("Configuration section test", "[config]")
|
||||
@ -128,13 +128,13 @@ TEST_CASE("Configuration section test", "[config]")
|
||||
false,
|
||||
1));
|
||||
|
||||
CHECK_THROWS(config.validate());
|
||||
CHECK_THROWS(config.validateRequiredFields());
|
||||
|
||||
config.addConfigValue("foo", "bar", "5");
|
||||
CHECK_THROWS(config.validate());
|
||||
CHECK_THROWS(config.validateRequiredFields());
|
||||
|
||||
CHECK_NOTHROW(config.addConfigValue("goo", "bar", "6"));
|
||||
CHECK_NOTHROW(config.validate());
|
||||
CHECK_NOTHROW(config.validateRequiredFields());
|
||||
|
||||
CHECK(config.getConfigValue<int>("foo", "bar") == 5);
|
||||
CHECK(config.getConfigValue<int>("goo", "bar") == 6);
|
||||
|
Loading…
Reference in New Issue
Block a user