]>
git.proxmox.com Git - libgit2.git/blob - tests/libgit2/refs/branches/lookup.c
1 #include "clar_libgit2.h"
4 static git_repository
*repo
;
5 static git_reference
*branch
;
7 void test_refs_branches_lookup__initialize(void)
9 cl_git_pass(git_repository_open(&repo
, cl_fixture("testrepo.git")));
14 void test_refs_branches_lookup__cleanup(void)
16 git_reference_free(branch
);
19 git_repository_free(repo
);
23 void test_refs_branches_lookup__can_retrieve_a_local_branch_local(void)
25 cl_git_pass(git_branch_lookup(&branch
, repo
, "br2", GIT_BRANCH_LOCAL
));
28 void test_refs_branches_lookup__can_retrieve_a_local_branch_all(void)
30 cl_git_pass(git_branch_lookup(&branch
, repo
, "br2", GIT_BRANCH_ALL
));
33 void test_refs_branches_lookup__trying_to_retrieve_a_local_branch_remote(void)
35 cl_git_fail(git_branch_lookup(&branch
, repo
, "br2", GIT_BRANCH_REMOTE
));
38 void test_refs_branches_lookup__can_retrieve_a_remote_tracking_branch_remote(void)
40 cl_git_pass(git_branch_lookup(&branch
, repo
, "test/master", GIT_BRANCH_REMOTE
));
43 void test_refs_branches_lookup__can_retrieve_a_remote_tracking_branch_all(void)
45 cl_git_pass(git_branch_lookup(&branch
, repo
, "test/master", GIT_BRANCH_ALL
));
48 void test_refs_branches_lookup__trying_to_retrieve_a_remote_tracking_branch_local(void)
50 cl_git_fail(git_branch_lookup(&branch
, repo
, "test/master", GIT_BRANCH_LOCAL
));
53 void test_refs_branches_lookup__trying_to_retrieve_an_unknown_branch_returns_ENOTFOUND(void)
55 cl_assert_equal_i(GIT_ENOTFOUND
, git_branch_lookup(&branch
, repo
, "where/are/you", GIT_BRANCH_LOCAL
));
56 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
));
60 void test_refs_branches_lookup__trying_to_retrieve_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void)
62 cl_assert_equal_i(GIT_EINVALIDSPEC
,
63 git_branch_lookup(&branch
, repo
, "are/you/inv@{id", GIT_BRANCH_LOCAL
));
64 cl_assert_equal_i(GIT_EINVALIDSPEC
,
65 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
));