Updates how config options are set on command line

This commit is contained in:
Jonathan Hodgson 2021-12-28 10:00:41 +00:00
parent 8bed39700e
commit f392af92c3
5 changed files with 56 additions and 22 deletions

View file

@ -63,6 +63,23 @@ MunitResult checkDefaults(const MunitParameter params[],
return MUNIT_OK;
}
MunitResult checkSetConfig(const MunitParameter params[],
void* user_data_or_fixture){
Config *conf = configDefaults();
setConfig(conf, "database", "test.blar");
munit_assert_string_equal(conf->database, "test.blar");
setConfig(conf, "localConfig", "test.blar");
munit_assert_string_equal(conf->localConfig, "test.blar");
setConfig(conf, "userConfig", "test.blar");
munit_assert_string_equal(conf->userConfig, "test.blar");
setConfig(conf, "port", "1234");
munit_assert_int(conf->port, ==, 1234);
return MUNIT_OK;
}
MunitTest tests[] = {
{
"/path_exists/yes", /* name */
@ -112,6 +129,14 @@ MunitTest tests[] = {
MUNIT_TEST_OPTION_NONE, /* options */
NULL /* parameters */
},
{
"/ConfigDir/SetConfigs", /* name */
checkSetConfig, /* test */
NULL, /* setup */
NULL, /* tear_down */
MUNIT_TEST_OPTION_NONE, /* options */
NULL /* parameters */
},
/* Mark the end of the array with an entry where the test
* function is NULL */
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }