"--key-file $key"
"$device"
"$volume")
- cryptsetup "${cryptsetupargs[@]}"
+ cryptsetup "${cryptsetupargs[@]}" \
+ || errlog "could not open $device with $key" \
+ || return $?
}
mount_backup()
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