diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-02-05 00:29:26 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-02-17 19:50:30 +0100 |
| commit | 3005855f7e3980185adc63a68c5b8b5f9e3b506f (patch) | |
| tree | 41e7d5c9a45928b8013f7fdd30d6b707a148f083 /tests-clar/config | |
| parent | 5e0dc4af013e23d0cbc737d8ab2756aaf38e1516 (diff) | |
| download | libgit2-3005855f7e3980185adc63a68c5b8b5f9e3b506f.tar.gz | |
Implement setting multivars
Diffstat (limited to 'tests-clar/config')
| -rw-r--r-- | tests-clar/config/multivar.c | 40 |
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); +} |
