Tests::Object::Tag: move listing tags tests to an own file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
diff --git a/tests-clar/object/tag/list.c b/tests-clar/object/tag/list.c
new file mode 100644
index 0000000..ed2cd4f
--- /dev/null
+++ b/tests-clar/object/tag/list.c
@@ -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);
+}
diff --git a/tests-clar/object/tag/read.c b/tests-clar/object/tag/read.c
index 6a0ad8a..4dd5cc2 100644
--- a/tests-clar/object/tag/read.c
+++ b/tests-clar/object/tag/read.c
@@ -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