Skip to content

Commit e35b5e4

Browse files
committed
test: add test for the behaviour of update_tips on error
1 parent 15860aa commit e35b5e4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/network/fetchlocal.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,3 +509,44 @@ void test_network_fetchlocal__prune_load_fetch_prune_config(void)
509509
git_remote_free(origin);
510510
git_repository_free(repo);
511511
}
512+
513+
static int update_tips_error(const char *ref, const git_oid *old, const git_oid *new, void *data)
514+
{
515+
int *callcount = (int *) data;
516+
517+
GIT_UNUSED(ref);
518+
GIT_UNUSED(old);
519+
GIT_UNUSED(new);
520+
521+
(*callcount)++;
522+
523+
return -1;
524+
}
525+
526+
void test_network_fetchlocal__update_tips_error_is_propagated(void)
527+
{
528+
git_repository *repo;
529+
git_reference_iterator *iterator;
530+
git_reference *ref;
531+
git_remote *remote;
532+
git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
533+
int callcount = 0;
534+
535+
cl_git_pass(git_repository_init(&repo, "foo.git", true));
536+
cl_set_cleanup(cleanup_local_repo, "foo.git");
537+
538+
cl_git_pass(git_remote_create_with_fetchspec(&remote, repo, "origin", cl_git_fixture_url("testrepo.git"), "+refs/heads/*:refs/remotes/update-tips/*"));
539+
540+
options.callbacks.update_tips = update_tips_error;
541+
options.callbacks.payload = &callcount;
542+
543+
cl_git_fail(git_remote_fetch(remote, NULL, &options, NULL));
544+
cl_assert_equal_i(1, callcount);
545+
546+
cl_git_pass(git_reference_iterator_glob_new(&iterator, repo, "refs/remotes/update-tips/**/"));
547+
cl_assert_equal_i(GIT_ITEROVER, git_reference_next(&ref, iterator));
548+
549+
git_reference_iterator_free(iterator);
550+
git_remote_free(remote);
551+
git_repository_free(repo);
552+
}

0 commit comments

Comments
 (0)