summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2017-03-06 13:13:47 +0000
committerEdward Thomson <ethomson@github.com>2017-03-06 14:11:00 +0000
commitd24ae06d72476a9d447c51c515500e784db061b2 (patch)
tree396bd5883d8d67c4c8c68293cfa495a83449722d
parent467185ff13d8995724425506a8ec71fc462a4e0d (diff)
downloadlibgit2-d24ae06d72476a9d447c51c515500e784db061b2.tar.gz
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.
-rw-r--r--tests/refs/namespaces.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/refs/namespaces.c b/tests/refs/namespaces.c
new file mode 100644
index 000000000..bb6bb1ce0
--- /dev/null
+++ b/tests/refs/namespaces.c
@@ -0,0 +1,36 @@
+#include "clar_libgit2.h"
+
+#include "repository.h"
+
+static git_repository *g_repo;
+
+void test_refs_namespaces__initialize(void)
+{
+ g_repo = cl_git_sandbox_init("testrepo");
+}
+
+void test_refs_namespaces__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_refs_namespaces__get_and_set(void)
+{
+ cl_assert_equal_s(NULL, git_repository_get_namespace(g_repo));
+
+ cl_git_pass(git_repository_set_namespace(g_repo, "namespace"));
+ cl_assert_equal_s("namespace", git_repository_get_namespace(g_repo));
+
+ cl_git_pass(git_repository_set_namespace(g_repo, NULL));
+ cl_assert_equal_s(NULL, git_repository_get_namespace(g_repo));
+}
+
+void test_refs_namespaces__namespace_doesnt_show_normal_refs(void)
+{
+ static git_strarray ref_list;
+
+ cl_git_pass(git_repository_set_namespace(g_repo, "namespace"));
+ cl_git_pass(git_reference_list(&ref_list, g_repo));
+ cl_assert_equal_i(0, ref_list.count);
+ git_strarray_free(&ref_list);
+}