Commit 668053be by Carlos Martín Nieto

filebuf: failing test for leaving the lockfile when failing to rename

When we fail to rename, we currently leave the lockfile laying
around. This shows that behaviour.
parent 4e0421fd
......@@ -124,3 +124,30 @@ void test_core_filebuf__umask(void)
cl_must_pass(p_unlink(test));
}
void test_core_filebuf__rename_error(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char *dir = "subdir", *test = "subdir/test", *test_lock = "subdir/test.lock";
int fd;
#ifndef GIT_WIN32
cl_skip();
#endif
cl_git_pass(p_mkdir(dir, 0666));
cl_git_mkfile(test, "dummy content");
fd = p_open(test, O_RDONLY);
cl_assert(fd > 0);
cl_git_pass(git_filebuf_open(&file, test, 0, 0666));
cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
cl_assert_equal_i(true, git_path_exists(test_lock));
cl_git_fail(git_filebuf_commit(&file));
p_close(fd);
git_filebuf_cleanup(&file);
cl_assert_equal_i(false, git_path_exists(test_lock));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment