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

index 10b7a3b3d3a28647882a3d3f50bdbd98f2182dbd..19cfa1742641df611a8a643c908a6d6697b470df 100755 (executable)
@@ -173,7 +173,9 @@ umount_backup()
 
        echo "ℹ️ INFO: close volume $volume"
        local cryptsetupargs=("close" "$volume")
-       cryptsetup "${cryptsetupargs[@]}"
+       cryptsetup "${cryptsetupargs[@]}" \
+               || errlog "could not close volume $volume" \
+               || return $?
 }
 
 main()
index 6fdc36034bbe8f67c807e874e123576353e6bc1f..9cdf46eada726ddf43ce3683ea55110680456c77 100755 (executable)
@@ -573,4 +573,26 @@ teardown() {
        assert_equal "$(awk 'NR==1 {print; exit}' "$CRYPTSETUP_LOG")" "2"
        assert_equal "$(awk 'NR==2 {print; exit}' "$CRYPTSETUP_LOG")" "close"
        assert_equal "$(awk 'NR==3 {print; exit}' "$CRYPTSETUP_LOG")" "luks-crypt-volume"
+}
+
+# bats test_tags=backupmount:umount
+@test "failure close volume with cryptsetup" {
+       umount() {
+               return 0
+       }
+       rmdir() {
+               return 0
+       }
+       cryptsetup() {
+               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 "ℹ️ INFO: close volume luks-crypt-volume"
+       assert_line --index 4 "❌ ERROR: could not close volume luks-crypt-volume"
 }
\ No newline at end of file