Skip to content

Commit a213fec

Browse files
Mr-Walletpks-t
authored andcommitted
tests: remote: add test suite to test listing remotes
There was a bug when calling `git_remote_list` that caused us to not re-read modified configurations when using `git_config_iterator`. This bug also impacted `git_remote_list`, which thus failed to provide an up-to-date list of remotes. Add a test suite remote::list with a single test that verifies we do the right thing.
1 parent 2766b92 commit a213fec

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/remote/list.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "clar_libgit2.h"
2+
#include "config/config_helpers.h"
3+
4+
static git_repository *_repo;
5+
6+
#define TEST_URL "http://github.com/libgit2/libgit2.git"
7+
8+
void test_remote_list__initialize(void)
9+
{
10+
_repo = cl_git_sandbox_init("testrepo");
11+
}
12+
13+
void test_remote_list__cleanup(void)
14+
{
15+
cl_git_sandbox_cleanup();
16+
}
17+
18+
void test_remote_list__always_checks_disk_config(void)
19+
{
20+
git_repository *repo;
21+
git_strarray remotes;
22+
git_remote *remote;
23+
24+
cl_git_pass(git_repository_open(&repo, git_repository_path(_repo)));
25+
26+
cl_git_pass(git_remote_list(&remotes, _repo));
27+
cl_assert_equal_sz(remotes.count, 1);
28+
git_strarray_free(&remotes);
29+
30+
cl_git_pass(git_remote_create(&remote, _repo, "valid-name", TEST_URL));
31+
32+
cl_git_pass(git_remote_list(&remotes, _repo));
33+
cl_assert_equal_sz(remotes.count, 2);
34+
git_strarray_free(&remotes);
35+
36+
cl_git_pass(git_remote_list(&remotes, repo));
37+
cl_assert_equal_sz(remotes.count, 2);
38+
git_strarray_free(&remotes);
39+
40+
git_repository_free(repo);
41+
git_remote_free(remote);
42+
}
43+

0 commit comments

Comments
 (0)