Test replacing a value Add a test to check that value replacement works. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/tests/resources/config/config9 b/tests/resources/config/config9
new file mode 100644
index 0000000..4359c78
--- /dev/null
+++ b/tests/resources/config/config9
@@ -0,0 +1,2 @@
+[core]
+ dummy = 1
diff --git a/tests/t15-config.c b/tests/t15-config.c
index 08a2cdb..c11c5a9 100644
--- a/tests/t15-config.c
+++ b/tests/t15-config.c
@@ -189,6 +189,27 @@ BEGIN_TEST(config8, "don't fail on empty files")
git_config_free(cfg);
END_TEST
+BEGIN_TEST
+(config9, "replace a value")
+ git_config *cfg;
+ int i;
+
+ /* By freeing the config, we make sure we flush the values */
+ must_pass(git_config_open_file(&cfg, CONFIG_BASE "/config9"));
+ must_pass(git_config_set_int(cfg, "core.dummy", 5));
+ git_config_free(cfg);
+
+ must_pass(git_config_open_file(&cfg, CONFIG_BASE "/config9"));
+ must_pass(git_config_get_int(cfg, "core.dummy", &i));
+ must_be_true(i == 5);
+ git_config_free(cfg);
+
+ must_pass(git_config_open_file(&cfg, CONFIG_BASE "/config9"));
+ must_pass(git_config_set_int(cfg, "core.dummy", 1));
+ git_config_free(cfg);
+
+END_TEST
+
BEGIN_SUITE(config)
ADD_TEST(config0);
ADD_TEST(config1);
@@ -199,4 +220,5 @@ BEGIN_SUITE(config)
ADD_TEST(config6);
ADD_TEST(config7);
ADD_TEST(config8);
+ ADD_TEST(config9);
END_SUITE