]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add test for crypt setup failed
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 15:36:30 +0000 (17:36 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 15:36:30 +0000 (17:36 +0200)
src/backupmount
tests/backupmount_tests.bats

index 1d1139f43274f13b431c10d490d56ba61b4ee9c9..fbbd8a0f7f47ef6dd73233db20fc3b9dc382500e 100755 (executable)
@@ -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()
index dde1a43ed60024a8d79d2edd4fda95d88a19994f..7c140806310072ea60f05a6150e537c23859196c 100755 (executable)
@@ -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