Commit 2f3074da512624c9522683f9aa6bca6642a3e4f7

Edward Thomson 2021-09-03T17:03:00

repo: refactor extensions tests into their own file

diff --git a/tests/repo/extensions.c b/tests/repo/extensions.c
new file mode 100644
index 0000000..8ba89f1
--- /dev/null
+++ b/tests/repo/extensions.c
@@ -0,0 +1,44 @@
+#include "clar_libgit2.h"
+#include "futils.h"
+#include "sysdir.h"
+#include <ctype.h>
+
+git_repository *repo;
+
+void test_repo_extensions__initialize(void)
+{
+	git_config *config;
+
+	repo = cl_git_sandbox_init("empty_bare.git");
+
+	cl_git_pass(git_repository_config(&config, repo));
+	cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 1));
+	git_config_free(config);
+}
+
+void test_repo_extensions__cleanup(void)
+{
+	cl_git_sandbox_cleanup();
+}
+
+void test_repo_extensions__builtin(void)
+{
+	git_repository *extended;
+
+	cl_repo_set_string(repo, "extensions.noop", "foobar");
+
+	cl_git_pass(git_repository_open(&extended, "empty_bare.git"));
+	cl_assert(git_repository_path(extended) != NULL);
+	cl_assert(git__suffixcmp(git_repository_path(extended), "/") == 0);
+	git_repository_free(extended);
+}
+
+void test_repo_extensions__unsupported(void)
+{
+	git_repository *extended = NULL;
+
+	cl_repo_set_string(repo, "extensions.unknown", "foobar");
+
+	cl_git_fail(git_repository_open(&extended, "empty_bare.git"));
+	git_repository_free(extended);
+}
diff --git a/tests/repo/open.c b/tests/repo/open.c
index 881a23d..bd60c12 100644
--- a/tests/repo/open.c
+++ b/tests/repo/open.c
@@ -42,48 +42,6 @@ void test_repo_open__format_version_1(void)
 	git_repository_free(repo);
 }
 
-void test_repo_open__format_version_1_with_valid_extension(void)
-{
-	git_repository *repo;
-	git_config *config;
-
-	repo = cl_git_sandbox_init("empty_bare.git");
-
-	cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
-	cl_git_pass(git_repository_config(&config, repo));
-
-	cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 1));
-	cl_git_pass(git_config_set_int32(config, "extensions.noop", 1));
-
-	git_config_free(config);
-	git_repository_free(repo);
-
-	cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
-	cl_assert(git_repository_path(repo) != NULL);
-	cl_assert(git__suffixcmp(git_repository_path(repo), "/") == 0);
-	git_repository_free(repo);
-}
-
-void test_repo_open__format_version_1_with_invalid_extension(void)
-{
-	git_repository *repo;
-	git_config *config;
-
-	repo = cl_git_sandbox_init("empty_bare.git");
-
-	cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
-	cl_git_pass(git_repository_config(&config, repo));
-
-	cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 1));
-	cl_git_pass(git_config_set_int32(config, "extensions.invalid", 1));
-
-	git_config_free(config);
-	git_repository_free(repo);
-
-	cl_git_fail(git_repository_open(&repo, "empty_bare.git"));
-	git_repository_free(repo);
-}
-
 void test_repo_open__standard_empty_repo_through_gitdir(void)
 {
 	git_repository *repo;