summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/network/remote/local.c35
-rw-r--r--tests/network/remote/remotes.c14
-rw-r--r--tests/online/push.c44
3 files changed, 39 insertions, 54 deletions
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c
index baeb25df4..55453061b 100644
--- a/tests/network/remote/local.c
+++ b/tests/network/remote/local.c
@@ -7,6 +7,14 @@ static git_repository *repo;
static git_buf file_path_buf = GIT_BUF_INIT;
static git_remote *remote;
+static char *push_refspec_strings[] = {
+ "refs/heads/master",
+};
+static git_strarray push_array = {
+ push_refspec_strings,
+ 1,
+};
+
void test_network_remote_local__initialize(void)
{
cl_git_pass(git_repository_init(&repo, "remotelocal/", 0));
@@ -191,9 +199,9 @@ void test_network_remote_local__push_to_bare_remote(void)
refspec_strings,
1,
};
+
/* Should be able to push to a bare remote */
git_remote *localremote;
- git_push *push;
/* Get some commits */
connect_to_local_repository(cl_fixture("testrepo.git"));
@@ -213,12 +221,9 @@ void test_network_remote_local__push_to_bare_remote(void)
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH));
/* Try to push */
- cl_git_pass(git_push_new(&push, localremote));
- cl_git_pass(git_push_add_refspec(push, "refs/heads/master"));
- cl_git_pass(git_push_finish(push));
+ cl_git_pass(git_remote_upload(remote, &push_array, NULL));
/* Clean up */
- git_push_free(push);
git_remote_free(localremote);
cl_fixture_cleanup("localbare.git");
}
@@ -234,7 +239,6 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
};
/* Should be able to push to a bare remote */
git_remote *localremote;
- git_push *push;
const char *url;
/* Get some commits */
@@ -258,12 +262,9 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH));
/* Try to push */
- cl_git_pass(git_push_new(&push, localremote));
- cl_git_pass(git_push_add_refspec(push, "refs/heads/master"));
- cl_git_pass(git_push_finish(push));
+ cl_git_pass(git_remote_upload(remote, &push_array, NULL));
/* Clean up */
- git_push_free(push);
git_remote_free(localremote);
cl_fixture_cleanup("localbare.git");
}
@@ -280,7 +281,6 @@ void test_network_remote_local__push_to_non_bare_remote(void)
};
/* Shouldn't be able to push to a non-bare remote */
git_remote *localremote;
- git_push *push;
/* Get some commits */
connect_to_local_repository(cl_fixture("testrepo.git"));
@@ -300,12 +300,9 @@ void test_network_remote_local__push_to_non_bare_remote(void)
cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH));
/* Try to push */
- cl_git_pass(git_push_new(&push, localremote));
- cl_git_pass(git_push_add_refspec(push, "refs/heads/master"));
- cl_git_fail_with(git_push_finish(push), GIT_EBAREREPO);
+ cl_git_fail_with(GIT_EBAREREPO, git_remote_upload(localremote, &push_array, NULL));
/* Clean up */
- git_push_free(push);
git_remote_free(localremote);
cl_fixture_cleanup("localbare.git");
}
@@ -433,7 +430,6 @@ void test_network_remote_local__update_tips_for_new_remote(void) {
git_repository *src_repo;
git_repository *dst_repo;
git_remote *new_remote;
- git_push *push;
git_reference* branch;
/* Copy test repo */
@@ -446,16 +442,13 @@ void test_network_remote_local__update_tips_for_new_remote(void) {
/* Push to bare repo */
cl_git_pass(git_remote_create(&new_remote, src_repo, "bare", "./localbare.git"));
cl_git_pass(git_remote_connect(new_remote, GIT_DIRECTION_PUSH));
- cl_git_pass(git_push_new(&push, new_remote));
- cl_git_pass(git_push_add_refspec(push, "refs/heads/master"));
- cl_git_pass(git_push_finish(push));
+ cl_git_pass(git_remote_upload(new_remote, &push_array, NULL));
/* Update tips and make sure remote branch has been created */
- cl_git_pass(git_push_update_tips(push, NULL, NULL));
+ cl_git_pass(git_remote_update_tips(new_remote, NULL, NULL));
cl_git_pass(git_branch_lookup(&branch, src_repo, "bare/master", GIT_BRANCH_REMOTE));
git_reference_free(branch);
- git_push_free(push);
git_remote_free(new_remote);
git_repository_free(dst_repo);
cl_fixture_cleanup("localbare.git");
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index 07ad934c7..995f1d541 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -72,7 +72,14 @@ void test_network_remote_remotes__error_when_not_found(void)
void test_network_remote_remotes__error_when_no_push_available(void)
{
git_remote *r;
- git_push *p;
+ char *specs = {
+ "refs/heads/master",
+ };
+ git_strarray arr = {
+ &specs,
+ 1,
+ };
+
cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git"), NULL));
@@ -83,11 +90,8 @@ void test_network_remote_remotes__error_when_no_push_available(void)
/* Make sure that push is really not available */
r->transport->push = NULL;
- cl_git_pass(git_push_new(&p, r));
- cl_git_pass(git_push_add_refspec(p, "refs/heads/master"));
- cl_git_fail_with(git_push_finish(p), GIT_ERROR);
+ cl_git_fail_with(-1, git_remote_upload(r, &arr, NULL));
- git_push_free(p);
git_remote_free(r);
}
diff --git a/tests/online/push.c b/tests/online/push.c
index 86862ee8f..1e30a1035 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -198,7 +198,7 @@ static void verify_tracking_branches(git_remote *remote, expected_ref expected_r
git_branch_t branch_type;
git_reference *ref;
- /* Get current remote branches */
+ /* Get current remote-tracking branches */
cl_git_pass(git_branch_iterator_new(&iter, remote->repo, GIT_BRANCH_REMOTE));
while ((error = git_branch_next(&ref, &branch_type, iter)) == 0) {
@@ -215,7 +215,7 @@ static void verify_tracking_branches(git_remote *remote, expected_ref expected_r
/* Loop through expected refs, make sure they exist */
for (i = 0; i < expected_refs_len; i++) {
- /* Convert remote reference name into tracking branch name.
+ /* Convert remote reference name into remote-tracking branch name.
* If the spec is not under refs/heads/, then skip.
*/
fetch_spec = git_remote__matching_refspec(remote, expected_refs[i].name);
@@ -318,8 +318,7 @@ void test_online_push__initialize(void)
{
git_vector delete_specs = GIT_VECTOR_INIT;
const git_remote_head **heads;
- size_t i, heads_len;
- char *curr_del_spec;
+ size_t heads_len;
_repo = cl_git_sandbox_init("push_src");
@@ -382,17 +381,12 @@ void test_online_push__initialize(void)
cl_git_pass(git_remote_ls(&heads, &heads_len, _remote));
cl_git_pass(create_deletion_refspecs(&delete_specs, heads, heads_len));
if (delete_specs.length) {
- git_push *push;
-
- cl_git_pass(git_push_new(&push, _remote));
+ git_strarray arr = {
+ (char **) delete_specs.contents,
+ delete_specs.length,
+ };
- git_vector_foreach(&delete_specs, i, curr_del_spec) {
- git_push_add_refspec(push, curr_del_spec);
- git__free(curr_del_spec);
- }
-
- cl_git_pass(git_push_finish(push));
- git_push_free(push);
+ cl_git_pass(git_remote_upload(_remote, &arr, NULL));
}
git_remote_disconnect(_remote);
@@ -818,30 +812,24 @@ void test_online_push__bad_refspecs(void)
/* All classes of refspecs that should be rejected by
* git_push_add_refspec() should go in this test.
*/
- git_push *push;
+ char *specs = {
+ "b6:b6",
+ };
+ git_strarray arr = {
+ &specs,
+ 1,
+ };
if (_remote) {
-/* cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH)); */
- cl_git_pass(git_push_new(&push, _remote));
-
- /* Unexpanded branch names not supported */
- cl_git_fail(git_push_add_refspec(push, "b6:b6"));
-
- git_push_free(push);
+ cl_git_fail(git_remote_upload(_remote, &arr, NULL));
}
}
void test_online_push__expressions(void)
{
- git_push *push;
-
/* TODO: Expressions in refspecs doesn't actually work yet */
const char *specs_left_expr[] = { "refs/heads/b2~1:refs/heads/b2" };
- cl_git_pass(git_push_new(&push, _remote));
- cl_git_fail(git_push_add_refspec(push, "refs/heads/b2:refs/heads/b2~1"));
- git_push_free(push);
-
/* TODO: Find a more precise way of checking errors than a exit code of -1. */
do_push(specs_left_expr, ARRAY_SIZE(specs_left_expr),
NULL, 0,