diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-28 16:09:17 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-28 16:09:17 +0200 |
| commit | 2b92283221114843c36e4e6372b5b793b2d5ffff (patch) | |
| tree | 217519a5b37c9ac01223875cbbc2ed5132b9f3cb /tests | |
| parent | c7f94123569e8fe00ffb3a35e6a12b6ebe9320ec (diff) | |
| parent | 9566ce430fde97d5e610bb2796d27d47e1e81ab5 (diff) | |
| download | libgit2-2b92283221114843c36e4e6372b5b793b2d5ffff.tar.gz | |
Merge pull request #3127 from libgit2/cmn/remote-fixups
Tackle remote API issues from bindings
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/network/remote/local.c | 10 | ||||
| -rw-r--r-- | tests/network/remote/remotes.c | 14 | ||||
| -rw-r--r-- | tests/online/remotes.c | 23 |
3 files changed, 21 insertions, 26 deletions
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c index 9d96184a2..5d726c958 100644 --- a/tests/network/remote/local.c +++ b/tests/network/remote/local.c @@ -39,7 +39,7 @@ static void connect_to_local_repository(const char *local_repository) { git_buf_sets(&file_path_buf, cl_git_path_url(local_repository)); - cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf), NULL)); + cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf))); cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL)); } @@ -71,7 +71,7 @@ void test_network_remote_local__retrieve_advertised_before_connect(void) git_buf_sets(&file_path_buf, cl_git_path_url(cl_fixture("testrepo.git"))); - cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf), NULL)); + cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf))); cl_git_fail(git_remote_ls(&refs, &refs_len, remote)); } @@ -213,7 +213,7 @@ void test_network_remote_local__push_to_bare_remote(void) } /* Connect to the bare repo */ - cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git", NULL)); + cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git")); cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL)); /* Try to push */ @@ -252,7 +252,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void) url = cl_git_path_url("./localbare.git"); /* Connect to the bare repo */ - cl_git_pass(git_remote_create_anonymous(&localremote, repo, url, NULL)); + cl_git_pass(git_remote_create_anonymous(&localremote, repo, url)); cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL)); /* Try to push */ @@ -289,7 +289,7 @@ void test_network_remote_local__push_to_non_bare_remote(void) } /* Connect to the bare repo */ - cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare", NULL)); + cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare")); cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL)); /* Try to push */ diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c index f81c1ccc0..2fa21d460 100644 --- a/tests/network/remote/remotes.c +++ b/tests/network/remote/remotes.c @@ -90,7 +90,7 @@ void test_network_remote_remotes__error_when_no_push_available(void) }; - cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git"), NULL)); + cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git"))); callbacks.transport = git_transport_local; cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH, &callbacks)); @@ -128,6 +128,8 @@ void test_network_remote_remotes__add_fetchspec(void) cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*"); cl_assert_equal_s(git_refspec_string(_refspec), "refs/*:refs/*"); cl_assert_equal_b(_refspec->push, false); + + cl_git_fail_with(GIT_EINVALIDSPEC, git_remote_add_fetch(_repo, "test", "refs/*/foo/*:refs/*")); } void test_network_remote_remotes__dup(void) @@ -465,13 +467,3 @@ void test_network_remote_remotes__query_refspecs(void) git_remote_free(remote); git_remote_delete(_repo, "test"); } - -void test_network_remote_remotes__fetch_from_anonymous(void) -{ - git_remote *remote; - - cl_git_pass(git_remote_create_anonymous(&remote, _repo, cl_fixture("testrepo.git"), - "refs/heads/*:refs/other/*")); - cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL)); - git_remote_free(remote); -} diff --git a/tests/online/remotes.c b/tests/online/remotes.c index 70374be2f..a86f2d9ae 100644 --- a/tests/online/remotes.c +++ b/tests/online/remotes.c @@ -1,19 +1,12 @@ #include "clar_libgit2.h" +static const char *refspec = "refs/heads/first-merge:refs/remotes/origin/first-merge"; + static int remote_single_branch(git_remote **out, git_repository *repo, const char *name, const char *url, void *payload) { - char *fetch_refspecs[] = { - "refs/heads/first-merge:refs/remotes/origin/first-merge", - }; - git_strarray fetch_refspecs_strarray = { - fetch_refspecs, - 1, - }; - GIT_UNUSED(payload); - cl_git_pass(git_remote_create(out, repo, name, url)); - cl_git_pass(git_remote_set_fetch_refspecs(*out, &fetch_refspecs_strarray)); + cl_git_pass(git_remote_create_with_fetchspec(out, repo, name, url, refspec)); return 0; } @@ -22,6 +15,7 @@ void test_online_remotes__single_branch(void) { git_clone_options opts = GIT_CLONE_OPTIONS_INIT; git_repository *repo; + git_remote *remote; git_strarray refs; size_t i, count = 0; @@ -38,6 +32,15 @@ void test_online_remotes__single_branch(void) cl_assert_equal_i(1, count); git_strarray_free(&refs); + + cl_git_pass(git_remote_lookup(&remote, repo, "origin")); + cl_git_pass(git_remote_get_fetch_refspecs(&refs, remote)); + + cl_assert_equal_i(1, refs.count); + cl_assert_equal_s(refspec, refs.strings[0]); + + git_strarray_free(&refs); + git_remote_free(remote); git_repository_free(repo); } |
