diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-04-22 16:16:27 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-04-22 16:16:27 +0200 |
commit | f564017d964e97c067baf98d2a332873bb641ffc (patch) | |
tree | 61666f5319491835e0bbd1119294dbedaec467f8 | |
parent | aaf42c8df75a78344e3e231260a935d2e034d8eb (diff) | |
parent | fc6f044ea3963eeee1a422de18c04fb29a2541fb (diff) | |
download | libgit2-f564017d964e97c067baf98d2a332873bb641ffc.tar.gz |
Merge pull request #3065 from cthomas/master
Fix for Issue #3023 tests fail with no network
-rw-r--r-- | tests/network/remote/remotes.c | 51 | ||||
-rw-r--r-- | tests/online/remotes.c | 52 |
2 files changed, 52 insertions, 51 deletions
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c index e750f7b1e..3e6e438cc 100644 --- a/tests/network/remote/remotes.c +++ b/tests/network/remote/remotes.c @@ -513,24 +513,6 @@ void test_network_remote_remotes__query_refspecs(void) git_remote_free(remote); } -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)); - - return 0; -} - void test_network_remote_remotes__fetch_from_anonymous(void) { git_remote *remote; @@ -540,36 +522,3 @@ void test_network_remote_remotes__fetch_from_anonymous(void) cl_git_pass(git_remote_fetch(remote, NULL, NULL)); git_remote_free(remote); } - -void test_network_remote_remotes__single_branch(void) -{ - git_clone_options opts = GIT_CLONE_OPTIONS_INIT; - git_repository *repo; - git_strarray refs; - size_t i, count = 0; - - opts.remote_cb = remote_single_branch; - opts.checkout_branch = "first-merge"; - - cl_git_pass(git_clone(&repo, "git://github.com/libgit2/TestGitRepository", "./single-branch", &opts)); - cl_git_pass(git_reference_list(&refs, repo)); - - for (i = 0; i < refs.count; i++) { - if (!git__prefixcmp(refs.strings[i], "refs/heads/")) - count++; - } - cl_assert_equal_i(1, count); - - git_strarray_free(&refs); - git_repository_free(repo); -} - -void test_network_remote_remotes__restricted_refspecs(void) -{ - git_clone_options opts = GIT_CLONE_OPTIONS_INIT; - git_repository *repo; - - opts.remote_cb = remote_single_branch; - - cl_git_fail_with(GIT_EINVALIDSPEC, git_clone(&repo, "git://github.com/libgit2/TestGitRepository", "./restrict-refspec", &opts)); -} diff --git a/tests/online/remotes.c b/tests/online/remotes.c new file mode 100644 index 000000000..70374be2f --- /dev/null +++ b/tests/online/remotes.c @@ -0,0 +1,52 @@ +#include "clar_libgit2.h" + +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)); + + return 0; +} + +void test_online_remotes__single_branch(void) +{ + git_clone_options opts = GIT_CLONE_OPTIONS_INIT; + git_repository *repo; + git_strarray refs; + size_t i, count = 0; + + opts.remote_cb = remote_single_branch; + opts.checkout_branch = "first-merge"; + + cl_git_pass(git_clone(&repo, "git://github.com/libgit2/TestGitRepository", "./single-branch", &opts)); + cl_git_pass(git_reference_list(&refs, repo)); + + for (i = 0; i < refs.count; i++) { + if (!git__prefixcmp(refs.strings[i], "refs/heads/")) + count++; + } + cl_assert_equal_i(1, count); + + git_strarray_free(&refs); + git_repository_free(repo); +} + +void test_online_remotes__restricted_refspecs(void) +{ + git_clone_options opts = GIT_CLONE_OPTIONS_INIT; + git_repository *repo; + + opts.remote_cb = remote_single_branch; + + cl_git_fail_with(GIT_EINVALIDSPEC, git_clone(&repo, "git://github.com/libgit2/TestGitRepository", "./restrict-refspec", &opts)); +} |