diff options
author | Vicent Marti <tanoku@gmail.com> | 2012-12-14 05:41:53 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2012-12-14 05:41:53 +0400 |
commit | b0b9fd32450227e36e2deae75e86a844ee34bd01 (patch) | |
tree | 2adc1737ed58462fa7b88109156a5e64f678c021 /tests-clar/clone | |
parent | 44f5f777aeca736a3ccbd2e099a608cc2687b508 (diff) | |
parent | 2b10a2b0e8f658af52ee806f1ab7e46eca37772f (diff) |
Merge remote-tracking branch 'origin/clone-auth' into development
Diffstat (limited to 'tests-clar/clone')
-rw-r--r-- | tests-clar/clone/network.c | 27 | ||||
-rw-r--r-- | tests-clar/clone/nonetwork.c | 25 |
2 files changed, 36 insertions, 16 deletions
diff --git a/tests-clar/clone/network.c b/tests-clar/clone/network.c index d519e458b..15ad95b37 100644 --- a/tests-clar/clone/network.c +++ b/tests-clar/clone/network.c @@ -5,14 +5,22 @@ CL_IN_CATEGORY("network") -#define LIVE_REPO_URL "git://github.com/libgit2/TestGitRepository" -#define LIVE_EMPTYREPO_URL "git://github.com/libgit2/TestEmptyRepository" +#define LIVE_REPO_URL "http://github.com/libgit2/TestGitRepository" +#define LIVE_EMPTYREPO_URL "http://github.com/libgit2/TestEmptyRepository" static git_repository *g_repo; +static git_remote *g_origin; void test_clone_network__initialize(void) { g_repo = NULL; + cl_git_pass(git_remote_new(&g_origin, NULL, "origin", LIVE_REPO_URL, GIT_REMOTE_DEFAULT_FETCH)); +} + +void test_clone_network__cleanup(void) +{ + git_remote_free(g_origin); + g_origin = NULL; } static void cleanup_repository(void *path) @@ -31,7 +39,7 @@ void test_clone_network__network_full(void) cl_set_cleanup(&cleanup_repository, "./test2"); - cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./test2", NULL, NULL, NULL)); + cl_git_pass(git_clone(&g_repo, g_origin, "./test2", NULL, NULL, NULL)); cl_assert(!git_repository_is_bare(g_repo)); cl_git_pass(git_remote_load(&origin, g_repo, "origin")); @@ -45,7 +53,7 @@ void test_clone_network__network_bare(void) cl_set_cleanup(&cleanup_repository, "./test"); - cl_git_pass(git_clone_bare(&g_repo, LIVE_REPO_URL, "./test", NULL, NULL)); + cl_git_pass(git_clone_bare(&g_repo, g_origin, "./test", NULL, NULL)); cl_assert(git_repository_is_bare(g_repo)); cl_git_pass(git_remote_load(&origin, g_repo, "origin")); @@ -57,7 +65,7 @@ void test_clone_network__cope_with_already_existing_directory(void) cl_set_cleanup(&cleanup_repository, "./foo"); p_mkdir("./foo", GIT_DIR_MODE); - cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./foo", NULL, NULL, NULL)); + cl_git_pass(git_clone(&g_repo, g_origin, "./foo", NULL, NULL, NULL)); git_repository_free(g_repo); g_repo = NULL; } @@ -67,7 +75,10 @@ void test_clone_network__empty_repository(void) cl_set_cleanup(&cleanup_repository, "./empty"); - cl_git_pass(git_clone(&g_repo, LIVE_EMPTYREPO_URL, "./empty", NULL, NULL, NULL)); + git_remote_free(g_origin); + cl_git_pass(git_remote_new(&g_origin, NULL, "origin", LIVE_EMPTYREPO_URL, GIT_REMOTE_DEFAULT_FETCH)); + + cl_git_pass(git_clone(&g_repo, g_origin, "./empty", NULL, NULL, NULL)); cl_assert_equal_i(true, git_repository_is_empty(g_repo)); cl_assert_equal_i(true, git_repository_head_orphan(g_repo)); @@ -85,7 +96,7 @@ void test_clone_network__can_prevent_the_checkout_of_a_standard_repo(void) cl_set_cleanup(&cleanup_repository, "./no-checkout"); - cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./no-checkout", NULL, NULL, NULL)); + cl_git_pass(git_clone(&g_repo, g_origin, "./no-checkout", NULL, NULL, NULL)); cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt")); cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&path))); @@ -121,7 +132,7 @@ void test_clone_network__can_checkout_a_cloned_repo(void) cl_set_cleanup(&cleanup_repository, "./default-checkout"); - cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./default-checkout", &opts, + cl_git_pass(git_clone(&g_repo, g_origin, "./default-checkout", &opts, &fetch_progress, &fetch_progress_cb_was_called)); cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt")); diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c index 84327081e..17a7a36ad 100644 --- a/tests-clar/clone/nonetwork.c +++ b/tests-clar/clone/nonetwork.c @@ -6,10 +6,18 @@ #define LIVE_REPO_URL "git://github.com/libgit2/TestGitRepository" static git_repository *g_repo; +static git_remote *g_origin = NULL; void test_clone_nonetwork__initialize(void) { g_repo = NULL; + cl_git_pass(git_remote_new(&g_origin, NULL, "origin", cl_git_fixture_url("testrepo.git"), GIT_REMOTE_DEFAULT_FETCH)); +} + +void test_clone_nonetwork__cleanup(void) +{ + git_remote_free(g_origin); + g_origin = NULL; } static void cleanup_repository(void *path) @@ -25,18 +33,20 @@ static void cleanup_repository(void *path) void test_clone_nonetwork__bad_url(void) { /* Clone should clean up the mess if the URL isn't a git repository */ - cl_git_fail(git_clone(&g_repo, "not_a_repo", "./foo", NULL, NULL, NULL)); + git_remote_free(g_origin); + cl_git_pass(git_remote_new(&g_origin, NULL, "origin", "not_a_repo", GIT_REMOTE_DEFAULT_FETCH)); + + cl_git_fail(git_clone(&g_repo, g_origin, "./foo", NULL, NULL, NULL)); cl_assert(!git_path_exists("./foo")); - cl_git_fail(git_clone_bare(&g_repo, "not_a_repo", "./foo.git", NULL, NULL)); + cl_git_fail(git_clone_bare(&g_repo, g_origin, "./foo.git", NULL, NULL)); cl_assert(!git_path_exists("./foo.git")); } void test_clone_nonetwork__local(void) { - const char *src = cl_git_fixture_url("testrepo.git"); cl_set_cleanup(&cleanup_repository, "./local"); - cl_git_pass(git_clone(&g_repo, src, "./local", NULL, NULL, NULL)); + cl_git_pass(git_clone(&g_repo, g_origin, "./local", NULL, NULL, NULL)); } void test_clone_nonetwork__local_absolute_path(void) @@ -49,10 +59,9 @@ void test_clone_nonetwork__local_absolute_path(void) void test_clone_nonetwork__local_bare(void) { - const char *src = cl_git_fixture_url("testrepo.git"); cl_set_cleanup(&cleanup_repository, "./local.git"); - cl_git_pass(git_clone_bare(&g_repo, src, "./local.git", NULL, NULL)); + cl_git_pass(git_clone_bare(&g_repo, g_origin, "./local.git", NULL, NULL)); } void test_clone_nonetwork__fail_when_the_target_is_a_file(void) @@ -60,7 +69,7 @@ void test_clone_nonetwork__fail_when_the_target_is_a_file(void) cl_set_cleanup(&cleanup_repository, "./foo"); cl_git_mkfile("./foo", "Bar!"); - cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", NULL, NULL, NULL)); + cl_git_fail(git_clone(&g_repo, g_origin, "./foo", NULL, NULL, NULL)); } void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(void) @@ -69,5 +78,5 @@ void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(vo p_mkdir("./foo", GIT_DIR_MODE); cl_git_mkfile("./foo/bar", "Baz!"); - cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", NULL, NULL, NULL)); + cl_git_fail(git_clone(&g_repo, g_origin, "./foo", NULL, NULL, NULL)); } |