Commit b3ba2e716b3edbf1453b228bae21c0bd3389e72a

Patrick Steinhardt 2019-03-29T11:15:26

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.

diff --git a/tests/config/global.c b/tests/config/global.c
index e10dbd7..2187919 100644
--- a/tests/config/global.c
+++ b/tests/config/global.c
@@ -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);