Commit 8689a69d by Sascha Cunz

Tests: Test remote's pushurl

parent 76501590
...@@ -27,8 +27,26 @@ void test_network_remotes__cleanup(void) ...@@ -27,8 +27,26 @@ void test_network_remotes__cleanup(void)
void test_network_remotes__parsing(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_name(_remote), "test");
cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2"); 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) void test_network_remotes__parsing_ssh_remote(void)
...@@ -81,6 +99,7 @@ void test_network_remotes__save(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_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_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_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)); cl_git_pass(git_remote_save(_remote));
git_remote_free(_remote); git_remote_free(_remote);
_remote = NULL; _remote = NULL;
...@@ -98,6 +117,9 @@ void test_network_remotes__save(void) ...@@ -98,6 +117,9 @@ void test_network_remotes__save(void)
cl_assert(_refspec != NULL); cl_assert(_refspec != NULL);
cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); 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_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) void test_network_remotes__fnmatch(void)
...@@ -143,13 +165,13 @@ void test_network_remotes__list(void) ...@@ -143,13 +165,13 @@ void test_network_remotes__list(void)
git_config *cfg; git_config *cfg;
cl_git_pass(git_remote_list(&list, _repo)); cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 1); cl_assert(list.count == 2);
git_strarray_free(&list); git_strarray_free(&list);
cl_git_pass(git_repository_config(&cfg, _repo)); 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_config_set_string(cfg, "remote.specless.url", "http://example.com"));
cl_git_pass(git_remote_list(&list, _repo)); cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 2); cl_assert(list.count == 3);
git_strarray_free(&list); git_strarray_free(&list);
git_config_free(cfg); git_config_free(cfg);
...@@ -180,4 +202,5 @@ void test_network_remotes__add(void) ...@@ -180,4 +202,5 @@ void test_network_remotes__add(void)
cl_assert(!strcmp(git_refspec_src(_refspec), "refs/heads/*")); cl_assert(!strcmp(git_refspec_src(_refspec), "refs/heads/*"));
cl_assert(git_refspec_force(_refspec) == 1); cl_assert(git_refspec_force(_refspec) == 1);
cl_assert(!strcmp(git_refspec_dst(_refspec), "refs/remotes/addtest/*")); cl_assert(!strcmp(git_refspec_dst(_refspec), "refs/remotes/addtest/*"));
cl_assert_equal_s(git_remote_url(_remote), "http://github.com/libgit2/libgit2");
} }
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
url = git://github.com/libgit2/libgit2 url = git://github.com/libgit2/libgit2
fetch = +refs/heads/*:refs/remotes/test/* 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"] [branch "master"]
remote = test remote = test
merge = refs/heads/master merge = refs/heads/master
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment