summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-03-06 15:11:11 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-04-18 15:55:25 +0200
commit36913b8cb497487728ee9bab383d4c1205685927 (patch)
treefc9e3a411b823e866dcbac57064e0a27c6534206 /tests
parent28fd7206b1359b6564bad3c66382b47a8f2e3eb1 (diff)
downloadlibgit2-36913b8cb497487728ee9bab383d4c1205685927.tar.gz
config: document current write behaviour in a test
On set, we set/add the value written to the config's internal values, but we do not refresh old values. Document this in a test in preparation for the refresh changes.
Diffstat (limited to 'tests')
-rw-r--r--tests/config/write.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/config/write.c b/tests/config/write.c
index 922d75557..f269c9571 100644
--- a/tests/config/write.c
+++ b/tests/config/write.c
@@ -304,3 +304,30 @@ void test_config_write__updating_a_locked_config_file_returns_ELOCKED(void)
git_config_free(cfg);
}
+void test_config_write__outside_change(void)
+{
+ int32_t tmp;
+ git_config *cfg;
+ const char *filename = "config-ext-change";
+
+ cl_git_mkfile(filename, "[old]\nvalue = 5\n");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, filename));
+
+ cl_git_pass(git_config_get_int32(&tmp, cfg, "old.value"));
+
+ /* Change the value on the file itself (simulate external process) */
+ cl_git_mkfile(filename, "[old]\nvalue = 6\n");
+
+ cl_git_pass(git_config_set_int32(cfg, "new.value", 7));
+
+ cl_git_pass(git_config_get_int32(&tmp, cfg, "old.value"));
+ cl_assert_equal_i(5, tmp);
+
+ cl_git_pass(git_config_refresh(cfg));
+
+ cl_git_pass(git_config_get_int32(&tmp, cfg, "old.value"));
+ cl_assert_equal_i(6, tmp);
+
+ git_config_free(cfg);
+}