Skip to content

Commit 0a25141

Browse files
committed
branch: add test for git_branch_lookup to accept GIT_BRANCH_ALL
1 parent 12c6e1f commit 0a25141

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

tests/refs/branches/lookup.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,41 @@ void test_refs_branches_lookup__cleanup(void)
2020
repo = NULL;
2121
}
2222

23-
void test_refs_branches_lookup__can_retrieve_a_local_branch(void)
23+
void test_refs_branches_lookup__can_retrieve_a_local_branch_local(void)
2424
{
2525
cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL));
2626
}
2727

28-
void test_refs_branches_lookup__can_retrieve_a_remote_tracking_branch(void)
28+
void test_refs_branches_lookup__can_retrieve_a_local_branch_all(void)
29+
{
30+
cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_ALL));
31+
}
32+
33+
void test_refs_branches_lookup__trying_to_retrieve_a_local_branch_remote(void)
34+
{
35+
cl_git_fail(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_REMOTE));
36+
}
37+
38+
void test_refs_branches_lookup__can_retrieve_a_remote_tracking_branch_remote(void)
2939
{
3040
cl_git_pass(git_branch_lookup(&branch, repo, "test/master", GIT_BRANCH_REMOTE));
3141
}
3242

43+
void test_refs_branches_lookup__can_retrieve_a_remote_tracking_branch_all(void)
44+
{
45+
cl_git_pass(git_branch_lookup(&branch, repo, "test/master", GIT_BRANCH_ALL));
46+
}
47+
48+
void test_refs_branches_lookup__trying_to_retrieve_a_remote_tracking_branch_local(void)
49+
{
50+
cl_git_fail(git_branch_lookup(&branch, repo, "test/master", GIT_BRANCH_LOCAL));
51+
}
52+
3353
void test_refs_branches_lookup__trying_to_retrieve_an_unknown_branch_returns_ENOTFOUND(void)
3454
{
3555
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_lookup(&branch, repo, "where/are/you", GIT_BRANCH_LOCAL));
3656
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_lookup(&branch, repo, "over/here", GIT_BRANCH_REMOTE));
57+
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_lookup(&branch, repo, "maybe/here", GIT_BRANCH_ALL));
3758
}
3859

3960
void test_refs_branches_lookup__trying_to_retrieve_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void)
@@ -42,4 +63,6 @@ void test_refs_branches_lookup__trying_to_retrieve_a_branch_with_an_invalid_name
4263
git_branch_lookup(&branch, repo, "are/you/inv@{id", GIT_BRANCH_LOCAL));
4364
cl_assert_equal_i(GIT_EINVALIDSPEC,
4465
git_branch_lookup(&branch, repo, "yes/i am", GIT_BRANCH_REMOTE));
66+
cl_assert_equal_i(GIT_EINVALIDSPEC,
67+
git_branch_lookup(&branch, repo, "inv al/id", GIT_BRANCH_ALL));
4568
}

0 commit comments

Comments
 (0)