diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-07-24 18:44:29 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-07-24 22:55:43 +0200 |
commit | 668053befecfd0979ff790bc9a2a3c308c38a9be (patch) | |
tree | b4aa1b4cbdb530383803862877d0b109b959044b | |
parent | 4e0421fdbdd54004041797b5dd5e79597c86f447 (diff) | |
download | libgit2-668053befecfd0979ff790bc9a2a3c308c38a9be.tar.gz |
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.
-rw-r--r-- | tests/core/filebuf.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/core/filebuf.c b/tests/core/filebuf.c index 5a3e7510f..9fd52b179 100644 --- a/tests/core/filebuf.c +++ b/tests/core/filebuf.c @@ -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)); + +} |