Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05ac705

Browse files
committed
remote: test for supported URLs in a single place
Instead of using ifdefs to run the tests, use them to set when we expect to support a particular scheme and always have the tests in the code.
1 parent ba67c07 commit 05ac705

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

tests/network/remote/remotes.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,24 @@ void test_network_remote_remotes__error_when_no_push_available(void)
9191
git_remote_free(r);
9292
}
9393

94-
void test_network_remote_remotes__supported_transport_methods_are_supported(void)
94+
void test_network_remote_remotes__supported_urls(void)
9595
{
96-
cl_assert(git_remote_supported_url("git://github.com/libgit2/libgit2"));
97-
cl_assert(git_remote_supported_url("http://github.com/libgit2/libgit2"));
96+
int ssh_supported = 0, https_supported = 0;
9897

9998
#ifdef GIT_SSH
100-
cl_assert(git_remote_supported_url("[email protected]:libgit2/libgit2.git"));
101-
cl_assert(git_remote_supported_url("ssh://[email protected]/libgit2/libgit2.git"));
99+
ssh_supported = 1;
102100
#endif
103101

104102
#if defined(GIT_SSL) || defined(GIT_WINHTTP)
105-
cl_assert(git_remote_supported_url("https://[email protected]/libgit2/libgit2.git"));
103+
https_supported = 1;
106104
#endif
107-
}
108105

109-
void test_network_remote_remotes__unsupported_transport_methods_are_unsupported(void)
110-
{
111-
#ifndef GIT_SSH
112-
cl_assert(!git_remote_supported_url("[email protected]:libgit2/libgit2.git"));
113-
cl_assert(!git_remote_supported_url("ssh://[email protected]/libgit2/libgit2.git"));
114-
#endif
106+
cl_assert(git_remote_supported_url("git://github.com/libgit2/libgit2"));
107+
cl_assert(git_remote_supported_url("http://github.com/libgit2/libgit2"));
115108

116-
#if !defined(GIT_SSL) && !defined(GIT_WINHTTP)
117-
cl_assert(!git_remote_supported_url("https://[email protected]/libgit2/libgit2.git"));
118-
#endif
109+
cl_assert_equal_i(ssh_supported, git_remote_supported_url("[email protected]:libgit2/libgit2.git"));
110+
cl_assert_equal_i(ssh_supported, git_remote_supported_url("ssh://[email protected]/libgit2/libgit2.git"));
111+
cl_assert_equal_i(https_supported, git_remote_supported_url("https://github.com/libgit2/libgit2.git"));
119112
}
120113

121114
void test_network_remote_remotes__refspec_parsing(void)

0 commit comments

Comments
 (0)