From: Bastian Dehn Date: Sun, 16 Aug 2026 18:14:22 +0000 (+0200) Subject: add failure test for close volume X-Git-Tag: v1.0.7^2~1^2~3 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=64c7e3da8fa9180e43ae8f13d7a7d737e662efd3;p=simple-backup.git add failure test for close volume --- diff --git a/src/backupmount b/src/backupmount index 10b7a3b..19cfa17 100755 --- a/src/backupmount +++ b/src/backupmount @@ -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() diff --git a/tests/backupmount_tests.bats b/tests/backupmount_tests.bats index 6fdc360..9cdf46e 100755 --- a/tests/backupmount_tests.bats +++ b/tests/backupmount_tests.bats @@ -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