Skip to content

Commit b3ba2e7

Browse files
committed
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.
1 parent 25c085e commit b3ba2e7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/config/global.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,23 @@ void test_config_global__cleanup(void)
3535
void test_config_global__open_global(void)
3636
{
3737
git_config *cfg, *global, *selected, *dummy;
38+
int32_t value;
39+
40+
cl_git_mkfile("home/.gitconfig", "[global]\n test = 4567\n");
3841

3942
cl_git_pass(git_config_open_default(&cfg));
43+
cl_git_pass(git_config_get_int32(&value, cfg, "global.test"));
44+
cl_assert_equal_i(4567, value);
45+
4046
cl_git_pass(git_config_open_level(&global, cfg, GIT_CONFIG_LEVEL_GLOBAL));
47+
cl_git_pass(git_config_get_int32(&value, global, "global.test"));
48+
cl_assert_equal_i(4567, value);
49+
4150
cl_git_fail(git_config_open_level(&dummy, cfg, GIT_CONFIG_LEVEL_XDG));
51+
4252
cl_git_pass(git_config_open_global(&selected, cfg));
53+
cl_git_pass(git_config_get_int32(&value, selected, "global.test"));
54+
cl_assert_equal_i(4567, value);
4355

4456
git_config_free(selected);
4557
git_config_free(global);

0 commit comments

Comments
 (0)