]> git.proxmox.com Git - libgit2.git/blob - tests/refs/branches/name.c
176f836a426e2c590b6390c585b59241237339c4
[libgit2.git] / tests / refs / branches / name.c
1 #include "clar_libgit2.h"
2 #include "branch.h"
3
4 static git_repository *repo;
5 static git_reference *ref;
6
7 void test_refs_branches_name__initialize(void)
8 {
9 cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
10 }
11
12 void test_refs_branches_name__cleanup(void)
13 {
14 git_reference_free(ref);
15 ref = NULL;
16
17 git_repository_free(repo);
18 repo = NULL;
19 }
20
21 void test_refs_branches_name__can_get_local_branch_name(void)
22 {
23 const char *name;
24
25 cl_git_pass(git_branch_lookup(&ref,repo,"master",GIT_BRANCH_LOCAL));
26 cl_git_pass(git_branch_name(&name,ref));
27 cl_assert_equal_s("master",name);
28 }
29
30 void test_refs_branches_name__can_get_remote_branch_name(void)
31 {
32 const char *name;
33
34 cl_git_pass(git_branch_lookup(&ref,repo,"test/master",GIT_BRANCH_REMOTE));
35 cl_git_pass(git_branch_name(&name,ref));
36 cl_assert_equal_s("test/master",name);
37 }
38
39 void test_refs_branches_name__error_when_ref_is_no_branch(void)
40 {
41 const char *name;
42
43 cl_git_pass(git_reference_lookup(&ref,repo,"refs/notes/fanout"));
44 cl_git_fail(git_branch_name(&name,ref));
45 }