diff options
author | Vicent Marti <tanoku@gmail.com> | 2013-11-20 12:54:24 +0100 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2013-11-20 12:54:24 +0100 |
commit | 4b0a36e881506a02b43a4ae3c19c93c919b36eeb (patch) | |
tree | 026182fa30273a4c1649928b6db3fc5335bd1ea4 /tests/refs/branches/upstreamname.c | |
parent | 29d7242b1dcd1f09a63417abd648a6217b85d301 (diff) | |
parent | 43cb8b32428b1b29994874349ec22eb5372e152c (diff) | |
download | libgit2-4b0a36e881506a02b43a4ae3c19c93c919b36eeb.tar.gz |
Merge branch 'development'
Diffstat (limited to 'tests/refs/branches/upstreamname.c')
-rw-r--r-- | tests/refs/branches/upstreamname.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/refs/branches/upstreamname.c b/tests/refs/branches/upstreamname.c new file mode 100644 index 000000000..f05607d44 --- /dev/null +++ b/tests/refs/branches/upstreamname.c @@ -0,0 +1,42 @@ +#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"))); + + git_buf_init(&upstream_name, 0); +} + +void test_refs_branches_upstreamname__cleanup(void) +{ + git_buf_free(&upstream_name); + + git_repository_free(repo); + repo = NULL; +} + +void test_refs_branches_upstreamname__can_retrieve_the_remote_tracking_reference_name_of_a_local_branch(void) +{ + cl_git_pass(git_branch_upstream__name( + &upstream_name, repo, "refs/heads/master")); + + cl_assert_equal_s("refs/remotes/test/master", git_buf_cstr(&upstream_name)); +} + +void test_refs_branches_upstreamname__can_retrieve_the_local_upstream_reference_name_of_a_local_branch(void) +{ + cl_git_pass(git_branch_upstream__name( + &upstream_name, repo, "refs/heads/track-local")); + + cl_assert_equal_s("refs/heads/master", git_buf_cstr(&upstream_name)); +} + +void test_refs_branches_upstreamname__can_return_the_size_of_thelocal_upstream_reference_name_of_a_local_branch(void) +{ + cl_assert_equal_i((int)strlen("refs/heads/master") + 1, + git_branch_upstream_name(NULL, 0, repo, "refs/heads/track-local")); +} |