mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-30 11:10:23 -04:00
test: config: verify we fail to load a config with an invalid section
This commit is contained in:
parent
11dfa2145f
commit
64787962ff
1 changed files with 16 additions and 0 deletions
|
|
@ -53,6 +53,12 @@ conf_file_teardown(void)
|
||||||
if (conf_file.path != NULL)
|
if (conf_file.path != NULL)
|
||||||
ck_assert_int_eq(unlink(conf_file.path), 0);
|
ck_assert_int_eq(unlink(conf_file.path), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
populate_config(struct file *file, const char *config)
|
||||||
|
{
|
||||||
|
const size_t len = strlen(config);
|
||||||
|
return write(file->fd, config, len) == len;
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(config_invalid_path)
|
START_TEST(config_invalid_path)
|
||||||
|
|
@ -68,6 +74,15 @@ START_TEST(config_empty_config)
|
||||||
&conf, conf_file.path, &user_notifications, &overrides, true);
|
&conf, conf_file.path, &user_notifications, &overrides, true);
|
||||||
ck_assert(success);
|
ck_assert(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
START_TEST(config_invalid_section)
|
||||||
|
{
|
||||||
|
static const char *config = "[invalid-section]\n";
|
||||||
|
ck_assert(populate_config(&conf_file, config));
|
||||||
|
|
||||||
|
bool success = config_load(
|
||||||
|
&conf, conf_file.path, &user_notifications, &overrides, true);
|
||||||
|
|
||||||
ck_assert(!success);
|
ck_assert(!success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,6 +95,7 @@ foot_suite(void)
|
||||||
tcase_add_checked_fixture(config, &conf_file_setup, &conf_file_teardown);
|
tcase_add_checked_fixture(config, &conf_file_setup, &conf_file_teardown);
|
||||||
tcase_add_test(config, config_invalid_path);
|
tcase_add_test(config, config_invalid_path);
|
||||||
tcase_add_test(config, config_empty_config);
|
tcase_add_test(config, config_empty_config);
|
||||||
|
tcase_add_test(config, config_invalid_section);
|
||||||
suite_add_tcase(suite, config);
|
suite_add_tcase(suite, config);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue