summaryrefslogtreecommitdiff
path: root/tests/config/include.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-08-01 13:23:16 +0200
committerPatrick Steinhardt <ps@pks.im>2019-08-01 13:35:51 +0200
commit835211dc4b6afef650222ca2e24545938e28e0cb (patch)
treef122732757ced3d298c229b3895fedab5da855e7 /tests/config/include.c
parent304e58c00487466aa5bd129b1eeb5169d75005e7 (diff)
downloadlibgit2-835211dc4b6afef650222ca2e24545938e28e0cb.tar.gz
tests: config: assert behaviour around includes
Add a few tests that verify some behaviour centered around includes. The first set of tests verifies that we correctly override values depending on the order of includes and other keys, the second set asserts that we can correctly snapshot configuration files with includes.
Diffstat (limited to 'tests/config/include.c')
-rw-r--r--tests/config/include.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/config/include.c b/tests/config/include.c
index 48261dd92..e2b0fc96c 100644
--- a/tests/config/include.c
+++ b/tests/config/include.c
@@ -202,3 +202,33 @@ void test_config_include__included_variables_cannot_be_modified(void)
cl_git_pass(p_unlink("top-level"));
cl_git_pass(p_unlink("included"));
}
+
+void test_config_include__variables_in_included_override_including(void)
+{
+ int i;
+
+ cl_git_mkfile("top-level", "[foo]\nbar = 1\n[include]\npath = included");
+ cl_git_mkfile("included", "[foo]\nbar = 2");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
+ cl_git_pass(git_config_get_int32(&i, cfg, "foo.bar"));
+ cl_assert_equal_i(i, 2);
+
+ cl_git_pass(p_unlink("top-level"));
+ cl_git_pass(p_unlink("included"));
+}
+
+void test_config_include__variables_in_including_override_included(void)
+{
+ int i;
+
+ cl_git_mkfile("top-level", "[include]\npath = included\n[foo]\nbar = 1");
+ cl_git_mkfile("included", "[foo]\nbar = 2");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
+ cl_git_pass(git_config_get_int32(&i, cfg, "foo.bar"));
+ cl_assert_equal_i(i, 1);
+
+ cl_git_pass(p_unlink("top-level"));
+ cl_git_pass(p_unlink("included"));
+}