Commit 7be5104d241ce84537076ad92d2ac1604ea33b8a

Ben Straub 2013-10-31T13:15:49

Add tests for badly-formed URLs

diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c
index 9eb4bf9..90e1e64 100644
--- a/tests-clar/clone/nonetwork.c
+++ b/tests-clar/clone/nonetwork.c
@@ -56,13 +56,9 @@ void test_clone_nonetwork__bad_urls(void)
 	cl_assert(!git_path_exists("./foo"));
 
 	cl_git_fail(git_clone(&g_repo, "git://example.com:asdf", "./foo", &g_options));
-	cl_assert(!git_path_exists("./foo"));
-	cl_git_fail(git_clone(&g_repo, "git://example.com:asdf/foo", "./foo", &g_options));
-	cl_assert(!git_path_exists("./foo"));
-	cl_git_fail(git_clone(&g_repo, "https://example.com:asdf", "./foo", &g_options));
-	cl_assert(!git_path_exists("./foo"));
 	cl_git_fail(git_clone(&g_repo, "https://example.com:asdf/foo", "./foo", &g_options));
-	cl_assert(!git_path_exists("./foo"));
+	cl_git_fail(git_clone(&g_repo, "git://github.com/git://github.com/foo/bar.git.git",
+				"./bar", &g_options));
 }
 
 void test_clone_nonetwork__do_not_clean_existing_directory(void)
diff --git a/tests-clar/network/urlparse.c b/tests-clar/network/urlparse.c
index 274d7e9..15e841b 100644
--- a/tests-clar/network/urlparse.c
+++ b/tests-clar/network/urlparse.c
@@ -31,6 +31,13 @@ void test_network_urlparse__trivial(void)
 	cl_assert_equal_p(pass, NULL);
 }
 
+void test_network_urlparse__bad_url(void)
+{
+	cl_git_fail_with(gitno_extract_url_parts(&host, &port, &user, &pass,
+				"github.com/git://github.com/foo/bar.git.git", "443"),
+			GIT_EINVALIDSPEC);
+}
+
 void test_network_urlparse__user(void)
 {
 	cl_git_pass(gitno_extract_url_parts(&host, &port, &user, &pass,