Skip to content

Commit e886ab4

Browse files
committed
tests: Add some more tests for git_futils_rmdir_r
Signed-off-by: Sven Strickroth <email@cs-ware.de>
1 parent 1621a37 commit e886ab4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/core/rmdir.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ void test_core_rmdir__initialize(void)
3030
/* make sure empty dir can be deleted recusively */
3131
void test_core_rmdir__delete_recursive(void)
3232
{
33+
git_buf path = GIT_BUF_INIT;
34+
cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one"));
35+
cl_assert(git_path_exists(git_buf_cstr(&path)));
36+
3337
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
38+
39+
cl_assert(!git_path_exists(git_buf_cstr(&path)));
40+
41+
git_buf_dispose(&path);
3442
}
3543

3644
/* make sure non-empty dir cannot be deleted recusively */
@@ -47,9 +55,17 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void)
4755
cl_must_pass(p_unlink(file.ptr));
4856
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
4957

58+
cl_assert(!git_path_exists(empty_tmp_dir));
59+
5060
git_buf_dispose(&file);
5161
}
5262

63+
void test_core_rmdir__keep_base(void)
64+
{
65+
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_ROOT));
66+
cl_assert(git_path_exists(empty_tmp_dir));
67+
}
68+
5369
void test_core_rmdir__can_skip_non_empty_dir(void)
5470
{
5571
git_buf file = GIT_BUF_INIT;

0 commit comments

Comments
 (0)