diff options
author | Vicent Marti <tanoku@gmail.com> | 2012-05-19 03:46:11 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2012-05-19 03:46:11 +0400 |
commit | 5b9fac39d8a76b9139667c26a63e6b3f204b3977 (patch) | |
tree | e6ba28025f92c16563c4ffa8bc60b95f17d69691 /tests-clar/refs/branches/move.c | |
parent | 7ef9f1b5606c2672105ecbbf34c022a71ef212fe (diff) | |
parent | ad5df35a47d56c3d716d7a56eac4aeb611987c11 (diff) |
Merge branch 'development'v0.17.0
Conflicts:
.travis.yml
Diffstat (limited to 'tests-clar/refs/branches/move.c')
-rw-r--r-- | tests-clar/refs/branches/move.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests-clar/refs/branches/move.c b/tests-clar/refs/branches/move.c new file mode 100644 index 000000000..242e5cd01 --- /dev/null +++ b/tests-clar/refs/branches/move.c @@ -0,0 +1,72 @@ +#include "clar_libgit2.h" +#include "branch.h" + +static git_repository *repo; + +void test_refs_branches_move__initialize(void) +{ + cl_fixture_sandbox("testrepo.git"); + cl_git_pass(git_repository_open(&repo, "testrepo.git")); +} + +void test_refs_branches_move__cleanup(void) +{ + git_repository_free(repo); + + cl_fixture_cleanup("testrepo.git"); +} + +#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)); +} + +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)); + + /* Upward */ + cl_git_pass(git_branch_move(repo, "somewhere/" NEW_BRANCH_NAME, "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)); + + /* Upward */ + cl_git_pass(git_branch_move(repo, "br2/" NEW_BRANCH_NAME, "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)); +} + +void test_refs_branches_move__can_not_move_a_non_existing_branch(void) +{ + cl_git_fail(git_branch_move(repo, "i-am-no-branch", NEW_BRANCH_NAME, 0)); +} + +void test_refs_branches_move__can_force_move_over_an_existing_branch(void) +{ + cl_git_pass(git_branch_move(repo, "br2", "master", 1)); +} + +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)); +} + +void test_refs_branches_move__moving_a_non_exisiting_branch_returns_ENOTFOUND(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); +} |