summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Strickroth <email@cs-ware.de>2018-10-02 19:50:29 +0200
committerSven Strickroth <email@cs-ware.de>2018-10-05 13:58:14 +0200
commite886ab46d73105868d7a4776b12e641f8bf0cfc3 (patch)
tree3d62bbffa000c095e27365ee943f31aecf7f3975
parent1621a37dd124c6d060b2197eed01155538b0a118 (diff)
downloadlibgit2-e886ab46d73105868d7a4776b12e641f8bf0cfc3.tar.gz
tests: Add some more tests for git_futils_rmdir_r
Signed-off-by: Sven Strickroth <email@cs-ware.de>
-rw-r--r--tests/core/rmdir.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/core/rmdir.c b/tests/core/rmdir.c
index 0ec5d6144..760cb5db2 100644
--- a/tests/core/rmdir.c
+++ b/tests/core/rmdir.c
@@ -30,7 +30,15 @@ void test_core_rmdir__initialize(void)
/* make sure empty dir can be deleted recusively */
void test_core_rmdir__delete_recursive(void)
{
+ git_buf path = GIT_BUF_INIT;
+ cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one"));
+ cl_assert(git_path_exists(git_buf_cstr(&path)));
+
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
+
+ cl_assert(!git_path_exists(git_buf_cstr(&path)));
+
+ git_buf_dispose(&path);
}
/* make sure non-empty dir cannot be deleted recusively */
@@ -47,9 +55,17 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void)
cl_must_pass(p_unlink(file.ptr));
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
+ cl_assert(!git_path_exists(empty_tmp_dir));
+
git_buf_dispose(&file);
}
+void test_core_rmdir__keep_base(void)
+{
+ cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_ROOT));
+ cl_assert(git_path_exists(empty_tmp_dir));
+}
+
void test_core_rmdir__can_skip_non_empty_dir(void)
{
git_buf file = GIT_BUF_INIT;