Skip to content

Commit d24ae06

Browse files
author
Edward Thomson
committed
refs::namespace: add namespace tests
These simple tests only ensure that we enforce the existence of a namespace; these mirror the rugged tests, they are not exhaustive.
1 parent 467185f commit d24ae06

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/refs/namespaces.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "clar_libgit2.h"
2+
3+
#include "repository.h"
4+
5+
static git_repository *g_repo;
6+
7+
void test_refs_namespaces__initialize(void)
8+
{
9+
g_repo = cl_git_sandbox_init("testrepo");
10+
}
11+
12+
void test_refs_namespaces__cleanup(void)
13+
{
14+
cl_git_sandbox_cleanup();
15+
}
16+
17+
void test_refs_namespaces__get_and_set(void)
18+
{
19+
cl_assert_equal_s(NULL, git_repository_get_namespace(g_repo));
20+
21+
cl_git_pass(git_repository_set_namespace(g_repo, "namespace"));
22+
cl_assert_equal_s("namespace", git_repository_get_namespace(g_repo));
23+
24+
cl_git_pass(git_repository_set_namespace(g_repo, NULL));
25+
cl_assert_equal_s(NULL, git_repository_get_namespace(g_repo));
26+
}
27+
28+
void test_refs_namespaces__namespace_doesnt_show_normal_refs(void)
29+
{
30+
static git_strarray ref_list;
31+
32+
cl_git_pass(git_repository_set_namespace(g_repo, "namespace"));
33+
cl_git_pass(git_reference_list(&ref_list, g_repo));
34+
cl_assert_equal_i(0, ref_list.count);
35+
git_strarray_free(&ref_list);
36+
}

0 commit comments

Comments
 (0)