fix: comment from verify config PR (#1823)

PR here: https://github.com/XRPLF/clio/pull/1814#
This commit is contained in:
Peter Chen
2025-01-13 12:58:20 -05:00
committed by GitHub
parent 9659d98140
commit c47b96bc68
4 changed files with 12 additions and 11 deletions

View File

@@ -41,13 +41,15 @@ verifyConfig(std::string_view configPath)
auto const json = ConfigFileJson::makeConfigFileJson(configPath);
if (!json.has_value()) {
std::cerr << json.error().error << std::endl;
std::cerr << "Error parsing json from config: " << configPath << "\n" << json.error().error << std::endl;
return false;
}
auto const errors = gClioConfig.parse(json.value());
if (errors.has_value()) {
for (auto const& err : errors.value())
for (auto const& err : errors.value()) {
std::cerr << "Issues found in provided config '" << configPath << "':\n";
std::cerr << err.error << std::endl;
}
return false;
}
return true;

View File

@@ -42,7 +42,7 @@ try {
[](app::CliArgs::Action::Exit const& exit) { return exit.exitCode; },
[](app::CliArgs::Action::VerifyConfig const& verify) {
if (app::verifyConfig(verify.configPath)) {
std::cout << "Config is correct" << "\n";
std::cout << "Config " << verify.configPath << " is correct" << "\n";
return EXIT_SUCCESS;
}
return EXIT_FAILURE;

View File

@@ -208,11 +208,3 @@ static constexpr auto kINVALID_JSON_DATA = R"JSON({
"withDefault" : "0.0"
}
})JSON";
// used to Verify Config test
static constexpr auto kVALID_JSON_DATA = R"JSON({
"server": {
"ip": "0.0.0.0",
"port": 51233
}
})JSON";

View File

@@ -36,6 +36,13 @@ TEST(VerifyConfigTest, InvalidConfig)
TEST(VerifyConfigTest, ValidConfig)
{
// used to Verify Config test
static constexpr auto kVALID_JSON_DATA = R"JSON({
"server": {
"ip": "0.0.0.0",
"port": 51233
}
})JSON";
auto const tmpConfigFile = TmpFile(kVALID_JSON_DATA);
// current example config should always be compatible with configDefinition