Skip to content

Commit

Permalink
fix: comment from verify config PR (#1823)
Browse files Browse the repository at this point in the history
PR here: #1814
  • Loading branch information
PeterChen13579 authored Jan 13, 2025
1 parent 9659d98 commit c47b96b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/app/VerifyConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions tests/common/util/newconfig/FakeConfigData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
7 changes: 7 additions & 0 deletions tests/unit/app/VerifyConfigTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c47b96b

Please sign in to comment.