upstreamname.c 906 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "clar_libgit2.h"
#include "branch.h"

static git_repository *repo;
static git_buf upstream_name;

void test_refs_branches_upstreamname__initialize(void)
{
	cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));

}

void test_refs_branches_upstreamname__cleanup(void)
{
15
	git_buf_dispose(&upstream_name);
16 17 18 19 20 21 22

	git_repository_free(repo);
	repo = NULL;
}

void test_refs_branches_upstreamname__can_retrieve_the_remote_tracking_reference_name_of_a_local_branch(void)
{
23
	cl_git_pass(git_branch_upstream_name(
24 25
		&upstream_name, repo, "refs/heads/master"));

26
	cl_assert_equal_s("refs/remotes/test/master", upstream_name.ptr);
27 28 29 30
}

void test_refs_branches_upstreamname__can_retrieve_the_local_upstream_reference_name_of_a_local_branch(void)
{
31
	cl_git_pass(git_branch_upstream_name(
32 33
		&upstream_name, repo, "refs/heads/track-local"));

34
	cl_assert_equal_s("refs/heads/master", upstream_name.ptr);
35
}