diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/opts.c | 46 | ||||
-rw-r--r-- | tests/repo/extensions.c | 28 |
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/core/opts.c b/tests/core/opts.c index 72408cbe8..e8f65d510 100644 --- a/tests/core/opts.c +++ b/tests/core/opts.c @@ -1,6 +1,11 @@ #include "clar_libgit2.h" #include "cache.h" +void test_core_opts__cleanup(void) +{ + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, NULL, 0)); +} + void test_core_opts__readwrite(void) { size_t old_val = 0; @@ -23,3 +28,44 @@ void test_core_opts__invalid_option(void) cl_git_fail(git_libgit2_opts(-1, "foobar")); } +void test_core_opts__extensions_query(void) +{ + git_strarray out = { 0 }; + + cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out)); + + cl_assert_equal_sz(out.count, 1); + cl_assert_equal_s("noop", out.strings[0]); + + git_strarray_dispose(&out); +} + +void test_core_opts__extensions_add(void) +{ + const char *in[] = { "foo" }; + git_strarray out = { 0 }; + + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in))); + cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out)); + + cl_assert_equal_sz(out.count, 2); + cl_assert_equal_s("noop", out.strings[0]); + cl_assert_equal_s("foo", out.strings[1]); + + git_strarray_dispose(&out); +} + +void test_core_opts__extensions_remove(void) +{ + const char *in[] = { "bar", "!negate", "!noop", "baz" }; + git_strarray out = { 0 }; + + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in))); + cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out)); + + cl_assert_equal_sz(out.count, 2); + cl_assert_equal_s("bar", out.strings[0]); + cl_assert_equal_s("baz", out.strings[1]); + + git_strarray_dispose(&out); +} diff --git a/tests/repo/extensions.c b/tests/repo/extensions.c index 8ba89f1a9..e7772acd5 100644 --- a/tests/repo/extensions.c +++ b/tests/repo/extensions.c @@ -19,6 +19,7 @@ void test_repo_extensions__initialize(void) void test_repo_extensions__cleanup(void) { cl_git_sandbox_cleanup(); + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, NULL, 0)); } void test_repo_extensions__builtin(void) @@ -33,6 +34,19 @@ void test_repo_extensions__builtin(void) git_repository_free(extended); } +void test_repo_extensions__negate_builtin(void) +{ + const char *in[] = { "foo", "!noop", "baz" }; + git_repository *extended; + + cl_repo_set_string(repo, "extensions.noop", "foobar"); + + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in))); + + cl_git_fail(git_repository_open(&extended, "empty_bare.git")); + git_repository_free(extended); +} + void test_repo_extensions__unsupported(void) { git_repository *extended = NULL; @@ -42,3 +56,17 @@ void test_repo_extensions__unsupported(void) cl_git_fail(git_repository_open(&extended, "empty_bare.git")); git_repository_free(extended); } + +void test_repo_extensions__adds_extension(void) +{ + const char *in[] = { "foo", "!noop", "newextension", "baz" }; + git_repository *extended; + + cl_repo_set_string(repo, "extensions.newextension", "foobar"); + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in))); + + 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); +} |