1
0
mirror of https://github.com/falk-werner/webfused synced 2024-10-27 20:44:08 +00:00

log syntax errors

This commit is contained in:
Falk Werner 2020-03-09 23:25:47 +01:00
parent 7e70d396f1
commit d8670b742c
2 changed files with 29 additions and 2 deletions

View File

@ -84,8 +84,16 @@ wfd_config_load_file(
if (CONFIG_TRUE == rc)
{
result = wfd_config_load(&config);
config_destroy(&config);
}
else
{
WFD_ERROR("failed to load config: %s: %d: %s",
config_error_file(&config),
config_error_line(&config),
config_error_text(&config));
}
config_destroy(&config);
return result;
}
@ -102,8 +110,15 @@ wfd_config_load_string(
if (CONFIG_TRUE == rc)
{
result = wfd_config_load(&config);
config_destroy(&config);
}
else
{
WFD_ERROR("failed to load config: %d: %s",
config_error_line(&config),
config_error_text(&config));
}
config_destroy(&config);
return result;
}

View File

@ -31,6 +31,18 @@ TEST(config, minimal_config)
wfd_config_dispose(config);
}
TEST(config, invalid_config)
{
MockLogger logger;
EXPECT_CALL(logger, log(WFD_LOGLEVEL_ERROR, _, _)).Times(1);
EXPECT_CALL(logger, onclose()).Times(1);
char const syntax_error[] = "version.major = 1\n";
struct wfd_config * config = wfd_config_load_string(syntax_error);
ASSERT_EQ(nullptr, config);
}
TEST(config, invalid_major_version_too_low)
{
MockLogger logger;