From 8689a69d097e1116e7fd2506b3cfd76b6e3b03bb Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Wed, 25 Jul 2012 01:59:23 +0200 Subject: [PATCH] Tests: Test remote's pushurl --- tests-clar/network/remotes.c | 27 ++++++++++++++++++++++-- tests-clar/resources/testrepo.git/config | 5 +++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c index eb7947dfb..61b29b85e 100644 --- a/tests-clar/network/remotes.c +++ b/tests-clar/network/remotes.c @@ -27,8 +27,26 @@ void test_network_remotes__cleanup(void) void test_network_remotes__parsing(void) { + git_remote *_remote2 = NULL; + cl_assert_equal_s(git_remote_name(_remote), "test"); cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2"); + cl_assert(git_remote_pushurl(_remote) == NULL); + + cl_git_pass(git_remote_load(&_remote2, _repo, "test_with_pushurl")); + cl_assert_equal_s(git_remote_name(_remote2), "test_with_pushurl"); + cl_assert_equal_s(git_remote_url(_remote2), "git://github.com/libgit2/fetchlibgit2"); + cl_assert_equal_s(git_remote_pushurl(_remote2), "git://github.com/libgit2/pushlibgit2"); + git_remote_free(_remote2); +} + +void test_network_remotes__pushurl(void) +{ + cl_git_pass(git_remote_set_pushurl(_remote, "git://github.com/libgit2/notlibgit2")); + cl_assert_equal_s(git_remote_pushurl(_remote), "git://github.com/libgit2/notlibgit2"); + + cl_git_pass(git_remote_set_pushurl(_remote, NULL)); + cl_assert(git_remote_pushurl(_remote) == NULL); } void test_network_remotes__parsing_ssh_remote(void) @@ -81,6 +99,7 @@ void test_network_remotes__save(void) cl_git_pass(git_remote_new(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2", NULL)); cl_git_pass(git_remote_set_fetchspec(_remote, "refs/heads/*:refs/remotes/upstream/*")); cl_git_pass(git_remote_set_pushspec(_remote, "refs/heads/*:refs/heads/*")); + cl_git_pass(git_remote_set_pushurl(_remote, "git://github.com/libgit2/libgit2_push")); cl_git_pass(git_remote_save(_remote)); git_remote_free(_remote); _remote = NULL; @@ -98,6 +117,9 @@ void test_network_remotes__save(void) cl_assert(_refspec != NULL); cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/heads/*"); + + cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2"); + cl_assert_equal_s(git_remote_pushurl(_remote), "git://github.com/libgit2/libgit2_push"); } void test_network_remotes__fnmatch(void) @@ -143,13 +165,13 @@ void test_network_remotes__list(void) git_config *cfg; cl_git_pass(git_remote_list(&list, _repo)); - cl_assert(list.count == 1); + cl_assert(list.count == 2); git_strarray_free(&list); cl_git_pass(git_repository_config(&cfg, _repo)); cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com")); cl_git_pass(git_remote_list(&list, _repo)); - cl_assert(list.count == 2); + cl_assert(list.count == 3); git_strarray_free(&list); git_config_free(cfg); @@ -180,4 +202,5 @@ void test_network_remotes__add(void) cl_assert(!strcmp(git_refspec_src(_refspec), "refs/heads/*")); cl_assert(git_refspec_force(_refspec) == 1); cl_assert(!strcmp(git_refspec_dst(_refspec), "refs/remotes/addtest/*")); + cl_assert_equal_s(git_remote_url(_remote), "http://github.com/libgit2/libgit2"); } diff --git a/tests-clar/resources/testrepo.git/config b/tests-clar/resources/testrepo.git/config index b4fdac6c2..c99d97153 100644 --- a/tests-clar/resources/testrepo.git/config +++ b/tests-clar/resources/testrepo.git/config @@ -7,6 +7,11 @@ url = git://github.com/libgit2/libgit2 fetch = +refs/heads/*:refs/remotes/test/* +[remote "test_with_pushurl"] + url = git://github.com/libgit2/fetchlibgit2 + pushurl = git://github.com/libgit2/pushlibgit2 + fetch = +refs/heads/*:refs/remotes/test_with_pushurl/* + [branch "master"] remote = test merge = refs/heads/master