add more pull conflict tests

Sun, 25 Aug 2019 11:42:55 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 25 Aug 2019 11:42:55 +0200
changeset 634
3ae1410b9d13
parent 633
b7de5ecc30fa
child 635
a6b1ec1b7ba0

add more pull conflict tests

test/bin-test/test-dav-sync-pull-conflict.sh file | annotate | diff | comparison | revisions
--- a/test/bin-test/test-dav-sync-pull-conflict.sh	Sun Aug 25 10:57:33 2019 +0200
+++ b/test/bin-test/test-dav-sync-pull-conflict.sh	Sun Aug 25 11:42:55 2019 +0200
@@ -93,6 +93,29 @@
 # prepare
 cp synctest/file1 tmp-sync/test1a
 cp synctest/file2 tmp-sync/test1a
+
+mkdir tmp-sync/test1a/dir1/
+mkdir tmp-sync/test1a/dir2/
+mkdir tmp-sync/test1a/dir1/subdir1/
+mkdir tmp-sync/test1a/dir2/subdir1/
+
+cp synctest/file1 tmp-sync/test1a/dir1/
+cp synctest/file2 tmp-sync/test1a/dir1/
+cp synctest/file3 tmp-sync/test1a/dir1/
+cp synctest/file4 tmp-sync/test1a/dir1/
+
+cp synctest/file1 tmp-sync/test1a/dir2/
+cp synctest/file2 tmp-sync/test1a/dir2/
+cp synctest/file3 tmp-sync/test1a/dir2/subdir1/
+cp synctest/file4 tmp-sync/test1a/dir2/subdir1/
+
+cp synctest/file1 tmp-sync/test1a/dir1/subdir1/
+cp synctest/file2 tmp-sync/test1a/dir1/subdir1/
+cp synctest/file3 tmp-sync/test1a/dir1/subdir1/
+cp synctest/file4 tmp-sync/test1a/dir1/subdir1/
+cp synctest/empty1 tmp-sync/test1a/dir1/subdir1/
+cp synctest/empty2 tmp-sync/test1a/dir1/subdir1/
+
 dav_sync_push test1a "prepare: push failed"
 dav_sync_pull test1b "prepare: pull failed"
 sleep 3
@@ -326,7 +349,7 @@
 
 # ----------------------------------------------------------------------------
 # 9. test: test1a deleted file, test1b modified file
-# expected result: conflict
+# expected result: no delete
 
 sleep 3 # make sure mtime changes
 
@@ -353,3 +376,83 @@
 	exit 2
 fi
 
+# ----------------------------------------------------------------------------
+# 10. test: test1a deleted 2 files in subdir, test1b modified one file
+# expected result: 1 delete
+
+# no sleep required, because we are working with other files
+
+rm -f tmp-sync/test1a/dir2/subdir1/file3
+rm -f tmp-sync/test1a/dir2/subdir1/file4
+
+dav_sync_push test1a "test 10: push failed"
+check_tmpout "2 files deleted" "test 10: wrong delete counter"
+check_tmpout "0 conflicts" "test 9: wrong conflict counter"
+
+echo "conflict1-test10-conflict" >> tmp-sync/test1b/dir2/subdir1/file4
+
+dav_sync_pull test1b "test 10: pull failed"
+# don't check conflict counter
+check_tmpout "1 file deleted" "test 10: wrong delete counter"
+
+cat tmp-sync/test1b/dir2/subdir1/file4 > /dev/null 2>&1
+if [ $? -ne 0 ]; then
+	echo "test 10: file4 deleted"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# 11. test: delete dir in test1a, modify 1 file in test1b
+# expected result: 1 remaining file
+
+# no sleep required, because we are working with other files
+
+rm -Rf tmp-sync/test1a/dir1
+
+dav_sync_push test1a "test 11: push failed"
+check_tmpout "0 conflicts" "test 11: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 11: wrong error counter (push)"
+
+echo "conflict1-test11-conflict" >> tmp-sync/test1b/dir1/file3
+
+dav_sync_pull test1b "test 11: pull failed"
+check_tmpout "0 errors" "test 11: wrong error counter (pull)"
+check_tmpout "delete: " "test 11: no deletes (pull)"
+
+TEST=`ls tmp-sync/test1b/dir1/ | wc -l`
+if [ $TEST != "1" ]; then
+	echo "test 11: wrong file count"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# 12. test: test1a modifies file, test1b deletes file
+# expected result: pull test1b restores deleted file
+
+# no sleep required, because we are working with other files
+
+echo "modified" >> tmp-sync/test1a/file2
+
+dav_sync_push test1a "test 12: push failed"
+check_tmpout "1 file pushed" "test 12: wrong push counter"
+check_tmpout "0 conflicts" "test 12: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 12: wrong error counter (push)"
+
+rm tmp-sync/test1b/file2
+
+dav_sync_pull test1b "test 12: pull failed"
+check_tmpout "1 file pulled" "test 12: wrong pull counter"
+check_tmpout "0 conflicts" "test 12: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 12: wrong error counter (pull)"
+
+cat tmp-sync/test1b/file2 > /dev/null 2>&1
+if [ $? -ne 0 ]; then
+	echo "test 12: file2 missing"
+	exit 2
+fi
+
+
+
+

mercurial