repository: separate head related tests
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
diff --git a/tests-clar/repo/getters.c b/tests-clar/repo/getters.c
index 966de1f..ffcd171 100644
--- a/tests-clar/repo/getters.c
+++ b/tests-clar/repo/getters.c
@@ -23,52 +23,6 @@ void test_repo_getters__empty(void)
git_repository_free(repo_empty);
}
-void test_repo_getters__head_detached(void)
-{
- git_repository *repo;
- git_reference *ref;
- git_oid oid;
-
- cl_git_pass(git_repository_open(&repo, "testrepo.git"));
-
- cl_assert(git_repository_head_detached(repo) == 0);
-
- /* detach the HEAD */
- git_oid_fromstr(&oid, "c47800c7266a2be04c571c04d5a6614691ea99bd");
- cl_git_pass(git_reference_create_oid(&ref, repo, "HEAD", &oid, 1));
- cl_assert(git_repository_head_detached(repo) == 1);
- git_reference_free(ref);
-
- /* take the reop back to it's original state */
- cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
- cl_assert(git_repository_head_detached(repo) == 0);
-
- git_reference_free(ref);
- git_repository_free(repo);
-}
-
-void test_repo_getters__head_orphan(void)
-{
- git_repository *repo;
- git_reference *ref;
-
- cl_git_pass(git_repository_open(&repo, "testrepo.git"));
-
- cl_assert(git_repository_head_orphan(repo) == 0);
-
- /* orphan HEAD */
- cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/orphan", 1));
- cl_assert(git_repository_head_orphan(repo) == 1);
- git_reference_free(ref);
-
- /* take the reop back to it's original state */
- cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
- cl_assert(git_repository_head_orphan(repo) == 0);
-
- git_reference_free(ref);
- git_repository_free(repo);
-}
-
void test_repo_getters__retrieving_the_odb_honors_the_refcount(void)
{
git_odb *odb;
diff --git a/tests-clar/repo/head.c b/tests-clar/repo/head.c
new file mode 100644
index 0000000..eb1332a
--- /dev/null
+++ b/tests-clar/repo/head.c
@@ -0,0 +1,52 @@
+#include "clar_libgit2.h"
+#include "refs.h"
+
+git_repository *repo;
+
+void test_repo_head__initialize(void)
+{
+ repo = cl_git_sandbox_init("testrepo.git");
+}
+
+void test_repo_head__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_repo_head__head_detached(void)
+{
+ git_reference *ref;
+ git_oid oid;
+
+ cl_assert(git_repository_head_detached(repo) == 0);
+
+ /* detach the HEAD */
+ git_oid_fromstr(&oid, "c47800c7266a2be04c571c04d5a6614691ea99bd");
+ cl_git_pass(git_reference_create_oid(&ref, repo, "HEAD", &oid, 1));
+ cl_assert(git_repository_head_detached(repo) == 1);
+ git_reference_free(ref);
+
+ /* take the reop back to it's original state */
+ cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
+ cl_assert(git_repository_head_detached(repo) == 0);
+
+ git_reference_free(ref);
+}
+
+void test_repo_head__head_orphan(void)
+{
+ git_reference *ref;
+
+ cl_assert(git_repository_head_orphan(repo) == 0);
+
+ /* orphan HEAD */
+ cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/orphan", 1));
+ cl_assert(git_repository_head_orphan(repo) == 1);
+ git_reference_free(ref);
+
+ /* take the reop back to it's original state */
+ cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
+ cl_assert(git_repository_head_orphan(repo) == 0);
+
+ git_reference_free(ref);
+}