Commit b3ba2e71 by Patrick Steinhardt

tests: config: verify that the global config is actually readable

While we do verify that we are able to open the global ".gitconfig" file
in config::global::open_global, we never verify that we it is in fact
readable. Do so by writing the global configuration file and verifying
that reading from it produces the expected values.
parent 25c085e6
......@@ -35,11 +35,23 @@ void test_config_global__cleanup(void)
void test_config_global__open_global(void)
{
git_config *cfg, *global, *selected, *dummy;
int32_t value;
cl_git_mkfile("home/.gitconfig", "[global]\n test = 4567\n");
cl_git_pass(git_config_open_default(&cfg));
cl_git_pass(git_config_get_int32(&value, cfg, "global.test"));
cl_assert_equal_i(4567, value);
cl_git_pass(git_config_open_level(&global, cfg, GIT_CONFIG_LEVEL_GLOBAL));
cl_git_pass(git_config_get_int32(&value, global, "global.test"));
cl_assert_equal_i(4567, value);
cl_git_fail(git_config_open_level(&dummy, cfg, GIT_CONFIG_LEVEL_XDG));
cl_git_pass(git_config_open_global(&selected, cfg));
cl_git_pass(git_config_get_int32(&value, selected, "global.test"));
cl_assert_equal_i(4567, value);
git_config_free(selected);
git_config_free(global);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment