]> git.proxmox.com Git - libgit2.git/blame - tests/refs/branches/lookup.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / refs / branches / lookup.c
CommitLineData
eed378b6 1#include "clar_libgit2.h"
2#include "refs.h"
3
4static git_repository *repo;
5static git_reference *branch;
6
7void test_refs_branches_lookup__initialize(void)
8{
9 cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
10
11 branch = NULL;
12}
13
14void test_refs_branches_lookup__cleanup(void)
15{
16 git_reference_free(branch);
9094d30b 17 branch = NULL;
eed378b6 18
19 git_repository_free(repo);
9094d30b 20 repo = NULL;
eed378b6 21}
22
22a2d3d5 23void test_refs_branches_lookup__can_retrieve_a_local_branch_local(void)
eed378b6 24{
25 cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL));
26}
27
22a2d3d5
UG
28void 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
33void 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
38void test_refs_branches_lookup__can_retrieve_a_remote_tracking_branch_remote(void)
eed378b6 39{
40 cl_git_pass(git_branch_lookup(&branch, repo, "test/master", GIT_BRANCH_REMOTE));
41}
42
22a2d3d5
UG
43void 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
48void 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
eed378b6 53void test_refs_branches_lookup__trying_to_retrieve_an_unknown_branch_returns_ENOTFOUND(void)
54{
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));
22a2d3d5 57 cl_assert_equal_i(GIT_ENOTFOUND, git_branch_lookup(&branch, repo, "maybe/here", GIT_BRANCH_ALL));
eed378b6 58}
62173038 59
60void test_refs_branches_lookup__trying_to_retrieve_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void)
61{
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));
22a2d3d5
UG
66 cl_assert_equal_i(GIT_EINVALIDSPEC,
67 git_branch_lookup(&branch, repo, "inv al/id", GIT_BRANCH_ALL));
62173038 68}