diff options
author | Etienne Samson <samson.etienne@gmail.com> | 2018-06-20 02:26:55 +0200 |
---|---|---|
committer | Etienne Samson <samson.etienne@gmail.com> | 2018-11-02 14:58:02 +0100 |
commit | 4e0da4501c3e4a43d519659f3d21aaf19646545a (patch) | |
tree | 2f32fb3a37d6aaad46751e033504fb07c50b1296 /tests/remote | |
parent | f778af68f8a00f9c1cae302317739715b3a394fe (diff) | |
download | libgit2-4e0da4501c3e4a43d519659f3d21aaf19646545a.tar.gz |
tests: check what happens with the remote. section counts
Diffstat (limited to 'tests/remote')
-rw-r--r-- | tests/remote/create.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/remote/create.c b/tests/remote/create.c index 28605c1eb..84dc0bec9 100644 --- a/tests/remote/create.c +++ b/tests/remote/create.c @@ -13,6 +13,24 @@ static git_config *_config; cl_assert_equal_p(r, NULL); \ } while (0); +static int cl_git_config_section_count__foreach(const git_config_entry *entry, void *payload) +{ + size_t *count = payload; + + GIT_UNUSED(entry); + (*count)++; + + return 0; +} + +static size_t cl_git_config_sections_count(git_config *cfg, const char *regex) +{ + size_t count = 0; + + cl_git_pass(git_config_foreach_match(cfg, regex, cl_git_config_section_count__foreach, &count)); + + return count; +} void test_remote_create__initialize(void) { @@ -51,6 +69,9 @@ void test_remote_create__named(void) git_remote *remote; git_config *cfg; const char *cfg_val; + + size_t section_count = cl_git_config_sections_count(_config, "remote."); + cl_git_pass(git_remote_create(&remote, _repo, "valid-name", TEST_URL)); cl_assert_equal_s(git_remote_name(remote), "valid-name"); @@ -64,6 +85,8 @@ void test_remote_create__named(void) cl_git_pass(git_config_get_string(&cfg_val, cfg, "remote.valid-name.url")); cl_assert_equal_s(cfg_val, TEST_URL); + cl_assert_equal_i(section_count + 2, cl_git_config_sections_count(_config, "remote.")); + git_config_free(cfg); git_remote_free(remote); } @@ -93,11 +116,13 @@ void test_remote_create__with_fetchspec(void) { git_remote *remote; git_strarray array; + size_t section_count = cl_git_config_sections_count(_config, "remote."); cl_git_pass(git_remote_create_with_fetchspec(&remote, _repo, "test-new", "git://github.com/libgit2/libgit2", "+refs/*:refs/*")); cl_git_pass(git_remote_get_fetch_refspecs(&array, remote)); cl_assert_equal_s("+refs/*:refs/*", array.strings[0]); cl_assert_equal_i(1, array.count); + cl_assert_equal_i(section_count + 2, cl_git_config_sections_count(_config, "remote.")); git_strarray_free(&array); git_remote_free(remote); @@ -107,10 +132,12 @@ void test_remote_create__with_empty_fetchspec(void) { git_remote *remote; git_strarray array; + size_t section_count = cl_git_config_sections_count(_config, "remote."); cl_git_pass(git_remote_create_with_fetchspec(&remote, _repo, "test-new", "git://github.com/libgit2/libgit2", NULL)); cl_git_pass(git_remote_get_fetch_refspecs(&array, remote)); cl_assert_equal_i(0, array.count); + cl_assert_equal_i(section_count + 1, cl_git_config_sections_count(_config, "remote.")); git_strarray_free(&array); git_remote_free(remote); @@ -130,6 +157,7 @@ void test_remote_create__anonymous(void) { git_remote *remote; git_strarray array; + size_t section_count = cl_git_config_sections_count(_config, "remote."); cl_git_pass(git_remote_create_anonymous(&remote, _repo, TEST_URL)); cl_assert_equal_s(git_remote_name(remote), NULL); @@ -137,6 +165,7 @@ void test_remote_create__anonymous(void) cl_git_pass(git_remote_get_fetch_refspecs(&array, remote)); cl_assert_equal_i(0, array.count); + cl_assert_equal_i(section_count, cl_git_config_sections_count(_config, "remote.")); git_strarray_free(&array); git_remote_free(remote); |