]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add test for failed delete directory
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 18:01:32 +0000 (20:01 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 18:01:32 +0000 (20:01 +0200)
src/backupmount
tests/backupmount_tests.bats

index 446411447a3edf18a91f634a06e1c1a453766ff2..630130a8a67b0a212473aafb38ede140dff13473 100755 (executable)
@@ -167,7 +167,9 @@ umount_backup()
                || return $?
 
        echo "ℹ️ INFO: remove backup directory $backup_path"
-       rmdir "$backup_path"
+       rmdir "$backup_path" \
+               || errlog "could not delete directory $backup_path" \
+               || return $?
 }
 
 main()
index 67166af20c6a6665227192d95cc29736d3724ec2..12b4b918e740639697c79303ca261cb75919282e 100755 (executable)
@@ -530,4 +530,22 @@ teardown() {
        assert_line --index 1 "ℹ️ INFO: umount backup path build/test"
        assert_line --index 2 "ℹ️ INFO: remove backup directory build/test"
        [ ! -d "build/test" ]
+}
+
+# bats test_tags=backupmount:umount
+@test "failure umount remove backup path directory" {
+       umount() {
+               return 0
+       }
+       rmdir() {
+               return 1
+       }
+
+       run main "umount"
+
+       assert_failure
+       assert_line --index 0 "⭐ START: backupmount"
+       assert_line --index 1 "ℹ️ INFO: umount backup path build/test"
+       assert_line --index 2 "ℹ️ INFO: remove backup directory build/test"
+       assert_line --index 3 "❌ ERROR: could not delete directory build/test"
 }
\ No newline at end of file