From: Bastian Dehn Date: Sun, 16 Aug 2026 15:36:30 +0000 (+0200) Subject: add test for crypt setup failed X-Git-Tag: v1.0.7^2~1^2~14 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=815b07c54ac3c72ced8b29c3a9b91ced11ca649a;p=simple-backup.git add test for crypt setup failed --- diff --git a/src/backupmount b/src/backupmount index 1d1139f..fbbd8a0 100755 --- a/src/backupmount +++ b/src/backupmount @@ -86,7 +86,9 @@ mount_device() "--key-file $key" "$device" "$volume") - cryptsetup "${cryptsetupargs[@]}" + cryptsetup "${cryptsetupargs[@]}" \ + || errlog "could not open $device with $key" \ + || return $? } mount_backup() diff --git a/tests/backupmount_tests.bats b/tests/backupmount_tests.bats index dde1a43..7c14080 100755 --- a/tests/backupmount_tests.bats +++ b/tests/backupmount_tests.bats @@ -248,4 +248,26 @@ teardown() { assert_equal "$(awk 'NR==3 {print; exit}' "$CRYPTSETUP_LOG")" "--key-file /path/to/luks-key-file-day" assert_equal "$(awk 'NR==4 {print; exit}' "$CRYPTSETUP_LOG")" "/dev/path/to/day" assert_equal "$(awk 'NR==5 {print; exit}' "$CRYPTSETUP_LOG")" "luks-crypt-volume" +} + +# bats test_tags=backupmount:mount +@test "failure open volume for media day" { + exists_block_device() { + return 0 + } + exists_key() { + return 0 + } + cryptsetup() { + return 1 + } + + run main "mount" + + assert_failure + assert_line --index 0 "⭐ START: backupmount" + assert_line --index 1 "ℹ️ INFO: media day with device /dev/path/to/day found" + assert_line --index 2 "ℹ️ INFO: use key /path/to/luks-key-file-day" + assert_line --index 3 "ℹ️ INFO: volume open luks-crypt-volume" + assert_line --index 4 "❌ ERROR: could not open /dev/path/to/day with /path/to/luks-key-file-day" } \ No newline at end of file