summaryrefslogtreecommitdiff
path: root/tests-clar/config/multivar.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests-clar/config/multivar.c')
-rw-r--r--tests-clar/config/multivar.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/tests-clar/config/multivar.c b/tests-clar/config/multivar.c
index 48d284da2..4cf5a37d6 100644
--- a/tests-clar/config/multivar.c
+++ b/tests-clar/config/multivar.c
@@ -4,7 +4,7 @@ static int mv_read_cb(const char *name, const char *GIT_UNUSED(value), void *dat
{
int *n = (int *) data;
- if (!strcmp(name, "remote.fancy.fetch"))
+ if (!strcmp(name, "remote.fancy.url"))
(*n)++;
return 0;
@@ -35,7 +35,7 @@ static int cb(const char *GIT_UNUSED(val), void *data)
void test_config_multivar__get(void)
{
git_config *cfg;
- const char *name = "remote.fancy.fetch";
+ const char *name = "remote.fancy.url";
int n;
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config11")));
@@ -50,3 +50,39 @@ void test_config_multivar__get(void)
git_config_free(cfg);
}
+
+void test_config_multivar__add(void)
+{
+ git_config *cfg;
+ const char *name = "remote.fancy.url";
+ int n;
+
+ cl_fixture_sandbox("config");
+ cl_git_pass(git_config_open_ondisk(&cfg, "config/config11"));
+ cl_git_pass(git_config_set_multivar(cfg, name, "^$", "git://git.otherplace.org/libgit2"));
+
+ n = 0;
+ cl_git_pass(git_config_get_multivar(cfg, name, NULL, cb, &n));
+ cl_assert(n == 3);
+
+ n = 0;
+ cl_git_pass(git_config_get_multivar(cfg, name, "otherplace", cb, &n));
+ cl_assert(n == 1);
+
+ git_config_free(cfg);
+
+ /* We know it works in memory, let's see if the file is written correctly */
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config/config11"));
+
+ n = 0;
+ cl_git_pass(git_config_get_multivar(cfg, name, NULL, cb, &n));
+ cl_assert(n == 3);
+
+
+ n = 0;
+ cl_git_pass(git_config_get_multivar(cfg, name, "otherplace", cb, &n));
+ cl_assert(n == 1);
+
+ git_config_free(cfg);
+}