summaryrefslogtreecommitdiff
path: root/tests/remote
diff options
context:
space:
mode:
authorJordan Wallet <JordanW@axosoft.com>2019-07-21 15:12:40 +0200
committerPatrick Steinhardt <ps@pks.im>2019-07-21 15:17:15 +0200
commita213fec64cb818d6a9538dd3682f7ef28693dd35 (patch)
treef0a35f05d70564ca502fd5ffd2daff890df7cc74 /tests/remote
parent2766b92de755871b666217912d865c46ed289011 (diff)
downloadlibgit2-a213fec64cb818d6a9538dd3682f7ef28693dd35.tar.gz
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.
Diffstat (limited to 'tests/remote')
-rw-r--r--tests/remote/list.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/remote/list.c b/tests/remote/list.c
new file mode 100644
index 000000000..5abb95106
--- /dev/null
+++ b/tests/remote/list.c
@@ -0,0 +1,43 @@
+#include "clar_libgit2.h"
+#include "config/config_helpers.h"
+
+static git_repository *_repo;
+
+#define TEST_URL "http://github.com/libgit2/libgit2.git"
+
+void test_remote_list__initialize(void)
+{
+ _repo = cl_git_sandbox_init("testrepo");
+}
+
+void test_remote_list__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_remote_list__always_checks_disk_config(void)
+{
+ git_repository *repo;
+ git_strarray remotes;
+ git_remote *remote;
+
+ cl_git_pass(git_repository_open(&repo, git_repository_path(_repo)));
+
+ cl_git_pass(git_remote_list(&remotes, _repo));
+ cl_assert_equal_sz(remotes.count, 1);
+ git_strarray_free(&remotes);
+
+ cl_git_pass(git_remote_create(&remote, _repo, "valid-name", TEST_URL));
+
+ cl_git_pass(git_remote_list(&remotes, _repo));
+ cl_assert_equal_sz(remotes.count, 2);
+ git_strarray_free(&remotes);
+
+ cl_git_pass(git_remote_list(&remotes, repo));
+ cl_assert_equal_sz(remotes.count, 2);
+ git_strarray_free(&remotes);
+
+ git_repository_free(repo);
+ git_remote_free(remote);
+}
+