diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-09-04 10:16:41 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-09-04 13:00:18 -0400 |
commit | a24e656a4e6278157d2aec885e0d300f47f74938 (patch) | |
tree | 793b046f71667ccb448c2138402c1be9afbb77b6 /tests/core/opts.c | |
parent | 2f3074da512624c9522683f9aa6bca6642a3e4f7 (diff) | |
download | libgit2-ethomson/extensions.tar.gz |
common: support custom repository extensionsethomson/extensions
Allow users to specify additional repository extensions that they want
to support. For example, callers can specify that they support
`preciousObjects` and then may open repositories that support
`extensions.preciousObjects`.
Similarly, callers may opt out of supporting extensions that the library
itself supports.
Diffstat (limited to 'tests/core/opts.c')
-rw-r--r-- | tests/core/opts.c | 46 |
1 files changed, 46 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); +} |