|
Packit Service |
20376f |
#include "clar_libgit2.h"
|
|
Packit Service |
20376f |
#include "refs.h"
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
static git_repository *repo;
|
|
Packit Service |
20376f |
static git_reference *branch;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_refs_branches_lookup__initialize(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
branch = NULL;
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_refs_branches_lookup__cleanup(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
git_reference_free(branch);
|
|
Packit Service |
20376f |
branch = NULL;
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
git_repository_free(repo);
|
|
Packit Service |
20376f |
repo = NULL;
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_refs_branches_lookup__can_retrieve_a_local_branch(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL));
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_refs_branches_lookup__can_retrieve_a_remote_tracking_branch(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
cl_git_pass(git_branch_lookup(&branch, repo, "test/master", GIT_BRANCH_REMOTE));
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_refs_branches_lookup__trying_to_retrieve_an_unknown_branch_returns_ENOTFOUND(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_lookup(&branch, repo, "where/are/you", GIT_BRANCH_LOCAL));
|
|
Packit Service |
20376f |
cl_assert_equal_i(GIT_ENOTFOUND, git_branch_lookup(&branch, repo, "over/here", GIT_BRANCH_REMOTE));
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
void test_refs_branches_lookup__trying_to_retrieve_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
cl_assert_equal_i(GIT_EINVALIDSPEC,
|
|
Packit Service |
20376f |
git_branch_lookup(&branch, repo, "are/you/inv@{id", GIT_BRANCH_LOCAL));
|
|
Packit Service |
20376f |
cl_assert_equal_i(GIT_EINVALIDSPEC,
|
|
Packit Service |
20376f |
git_branch_lookup(&branch, repo, "yes/i am", GIT_BRANCH_REMOTE));
|
|
Packit Service |
20376f |
}
|