Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-07-24 19:44:29 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-07-24 23:55:43 +0300
commit668053befecfd0979ff790bc9a2a3c308c38a9be (patch)
treeb4aa1b4cbdb530383803862877d0b109b959044b /tests
parent4e0421fdbdd54004041797b5dd5e79597c86f447 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/core/filebuf.c27
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));
+
+}