summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-07-20 16:34:08 +0200
committernulltoken <emeric.fermas@gmail.com>2012-07-24 16:09:47 +0200
commitbf9e8cc86b9c32946a395fd12a9b1a5cb71575a9 (patch)
treea1fc0a1a46a30a4ec809bfe276b50f80f5415f85 /tests-clar
parentabee7bd36a8a00e9578d3c94b1b7080f5b5c7dc8 (diff)
downloadlibgit2-bf9e8cc86b9c32946a395fd12a9b1a5cb71575a9.tar.gz
branch: make git_branch_move() reference based
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/refs/branches/move.c49
1 files changed, 21 insertions, 28 deletions
diff --git a/tests-clar/refs/branches/move.c b/tests-clar/refs/branches/move.c
index 258f74c3d..6750473e1 100644
--- a/tests-clar/refs/branches/move.c
+++ b/tests-clar/refs/branches/move.c
@@ -1,71 +1,64 @@
#include "clar_libgit2.h"
+#include "refs.h"
static git_repository *repo;
+static git_reference *ref;
void test_refs_branches_move__initialize(void)
{
- cl_fixture_sandbox("testrepo.git");
- cl_git_pass(git_repository_open(&repo, "testrepo.git"));
+ repo = cl_git_sandbox_init("testrepo.git");
+
+ cl_git_pass(git_reference_lookup(&ref, repo, "refs/heads/br2"));
}
void test_refs_branches_move__cleanup(void)
{
- git_repository_free(repo);
-
- cl_fixture_cleanup("testrepo.git");
+ git_reference_free(ref);
+ cl_git_sandbox_cleanup();
}
#define NEW_BRANCH_NAME "new-branch-on-the-block"
void test_refs_branches_move__can_move_a_local_branch(void)
{
- cl_git_pass(git_branch_move(repo, "br2", NEW_BRANCH_NAME, 0));
+ cl_git_pass(git_branch_move(ref, NEW_BRANCH_NAME, 0));
+ cl_assert_equal_s(GIT_REFS_HEADS_DIR NEW_BRANCH_NAME, git_reference_name(ref));
}
void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(void)
{
/* Downward */
- cl_git_pass(git_branch_move(repo, "br2", "somewhere/" NEW_BRANCH_NAME, 0));
+ cl_git_pass(git_branch_move(ref, "somewhere/" NEW_BRANCH_NAME, 0));
/* Upward */
- cl_git_pass(git_branch_move(repo, "somewhere/" NEW_BRANCH_NAME, "br2", 0));
+ cl_git_pass(git_branch_move(ref, "br2", 0));
}
void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_namespace(void)
{
/* Downward */
- cl_git_pass(git_branch_move(repo, "br2", "br2/" NEW_BRANCH_NAME, 0));
+ cl_git_pass(git_branch_move(ref, "br2/" NEW_BRANCH_NAME, 0));
/* Upward */
- cl_git_pass(git_branch_move(repo, "br2/" NEW_BRANCH_NAME, "br2", 0));
+ cl_git_pass(git_branch_move(ref, "br2", 0));
}
void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_collide_with_an_existing_one(void)
{
- cl_git_fail(git_branch_move(repo, "br2", "master", 0));
+ cl_git_fail(git_branch_move(ref, "master", 0));
}
-void test_refs_branches_move__can_not_move_a_non_existing_branch(void)
+void test_refs_branches_move__can_not_move_a_non_branch(void)
{
- cl_git_fail(git_branch_move(repo, "i-am-no-branch", NEW_BRANCH_NAME, 0));
-}
+ git_reference *tag;
-void test_refs_branches_move__can_force_move_over_an_existing_branch(void)
-{
- cl_git_pass(git_branch_move(repo, "br2", "master", 1));
-}
+ cl_git_pass(git_reference_lookup(&tag, repo, "refs/tags/e90810b"));
+ cl_git_fail(git_branch_move(tag, NEW_BRANCH_NAME, 0));
-void test_refs_branches_move__can_not_move_a_branch_through_its_canonical_name(void)
-{
- cl_git_fail(git_branch_move(repo, "refs/heads/br2", NEW_BRANCH_NAME, 1));
+ git_reference_free(tag);
}
-void test_refs_branches_move__moving_a_non_exisiting_branch_returns_ENOTFOUND(void)
+void test_refs_branches_move__can_force_move_over_an_existing_branch(void)
{
- int error;
-
- error = git_branch_move(repo, "where/am/I", NEW_BRANCH_NAME, 0);
- cl_git_fail(error);
-
- cl_assert_equal_i(GIT_ENOTFOUND, error);
+ cl_git_pass(git_branch_move(ref, "master", 1));
}