mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 23:39:38 +00:00
Tests::Object::Tag: move listing tags tests to an own file
This commit is contained in:
parent
3af06254d0
commit
f73f760e66
60
tests-clar/object/tag/list.c
Normal file
60
tests-clar/object/tag/list.c
Normal file
@ -0,0 +1,60 @@
|
||||
#include "clar_libgit2.h"
|
||||
|
||||
#include "tag.h"
|
||||
|
||||
static git_repository *g_repo;
|
||||
|
||||
// Helpers
|
||||
static void ensure_tag_pattern_match(git_repository *repo,
|
||||
const char *pattern,
|
||||
const size_t expected_matches)
|
||||
{
|
||||
git_strarray tag_list;
|
||||
int error = 0;
|
||||
|
||||
if ((error = git_tag_list_match(&tag_list, pattern, repo)) < 0)
|
||||
goto exit;
|
||||
|
||||
if (tag_list.count != expected_matches)
|
||||
error = GIT_ERROR;
|
||||
|
||||
exit:
|
||||
git_strarray_free(&tag_list);
|
||||
cl_git_pass(error);
|
||||
}
|
||||
|
||||
|
||||
// Fixture setup and teardown
|
||||
void test_object_tag_list__initialize(void)
|
||||
{
|
||||
g_repo = cl_git_sandbox_init("testrepo");
|
||||
}
|
||||
|
||||
void test_object_tag_list__cleanup(void)
|
||||
{
|
||||
cl_git_sandbox_cleanup();
|
||||
}
|
||||
|
||||
void test_object_tag_list__list_all(void)
|
||||
{
|
||||
// list all tag names from the repository
|
||||
git_strarray tag_list;
|
||||
|
||||
cl_git_pass(git_tag_list(&tag_list, g_repo));
|
||||
|
||||
cl_assert(tag_list.count == 3);
|
||||
|
||||
git_strarray_free(&tag_list);
|
||||
}
|
||||
|
||||
void test_object_tag_list__list_by_pattern(void)
|
||||
{
|
||||
// list all tag names from the repository matching a specified pattern
|
||||
ensure_tag_pattern_match(g_repo, "", 3);
|
||||
ensure_tag_pattern_match(g_repo, "*", 3);
|
||||
ensure_tag_pattern_match(g_repo, "t*", 1);
|
||||
ensure_tag_pattern_match(g_repo, "*b", 2);
|
||||
ensure_tag_pattern_match(g_repo, "e", 0);
|
||||
ensure_tag_pattern_match(g_repo, "e90810b", 1);
|
||||
ensure_tag_pattern_match(g_repo, "e90810[ab]", 1);
|
||||
}
|
@ -10,27 +10,6 @@ static const char *badly_tagged_commit = "e90810b8df3e80c413d903f631643c71688713
|
||||
|
||||
static git_repository *g_repo;
|
||||
|
||||
|
||||
// Helpers
|
||||
static void ensure_tag_pattern_match(git_repository *repo,
|
||||
const char *pattern,
|
||||
const size_t expected_matches)
|
||||
{
|
||||
git_strarray tag_list;
|
||||
int error = 0;
|
||||
|
||||
if ((error = git_tag_list_match(&tag_list, pattern, repo)) < 0)
|
||||
goto exit;
|
||||
|
||||
if (tag_list.count != expected_matches)
|
||||
error = GIT_ERROR;
|
||||
|
||||
exit:
|
||||
git_strarray_free(&tag_list);
|
||||
cl_git_pass(error);
|
||||
}
|
||||
|
||||
|
||||
// Fixture setup and teardown
|
||||
void test_object_tag_read__initialize(void)
|
||||
{
|
||||
@ -74,30 +53,6 @@ void test_object_tag_read__parse(void)
|
||||
git_commit_free(commit);
|
||||
}
|
||||
|
||||
void test_object_tag_read__list(void)
|
||||
{
|
||||
// list all tag names from the repository
|
||||
git_strarray tag_list;
|
||||
|
||||
cl_git_pass(git_tag_list(&tag_list, g_repo));
|
||||
|
||||
cl_assert(tag_list.count == 3);
|
||||
|
||||
git_strarray_free(&tag_list);
|
||||
}
|
||||
|
||||
void test_object_tag_read__list_pattern(void)
|
||||
{
|
||||
// list all tag names from the repository matching a specified pattern
|
||||
ensure_tag_pattern_match(g_repo, "", 3);
|
||||
ensure_tag_pattern_match(g_repo, "*", 3);
|
||||
ensure_tag_pattern_match(g_repo, "t*", 1);
|
||||
ensure_tag_pattern_match(g_repo, "*b", 2);
|
||||
ensure_tag_pattern_match(g_repo, "e", 0);
|
||||
ensure_tag_pattern_match(g_repo, "e90810b", 1);
|
||||
ensure_tag_pattern_match(g_repo, "e90810[ab]", 1);
|
||||
}
|
||||
|
||||
void test_object_tag_read__parse_without_tagger(void)
|
||||
{
|
||||
// read and parse a tag without a tagger field
|
||||
|
Loading…
Reference in New Issue
Block a user