local backup_path="$2"
echo "ℹ️ INFO: create backup path $backup_path"
- mkdir --parents "$backup_path"
+ mkdir --parents "$backup_path" \
+ || errlog "could not create backup path $backup_path" \
+ || return $?
echo "ℹ️ INFO: mount $partition to $backup_path"
- mount "$partition" "$backup_path"
+ mount "$partition" "$backup_path" \
+ || errlog "could not mount $partition to $backup_path" \
+ || return $?
}
mount_device()
assert_equal "$(awk 'NR==1 {print; exit}' "$MOUNT_LOG")" "2"
assert_equal "$(awk 'NR==2 {print; exit}' "$MOUNT_LOG")" "/dev/path/to/partday"
assert_equal "$(awk 'NR==3 {print; exit}' "$MOUNT_LOG")" "build/test"
+}
+
+# bats test_tags=backupmount:mount
+@test "failure mount partition mkdir failed" {
+ exists_block_device() {
+ return 0
+ }
+ exists_key() {
+ return 0
+ }
+ cryptsetup() {
+ return 0
+ }
+ exists_partition() {
+ return 0
+ }
+ mkdir() {
+ 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 "ℹ️ INFO: create backup path build/test"
+ assert_line --index 5 "❌ ERROR: could not create backup path build/test"
+}
+
+# bats test_tags=backupmount:mount
+@test "failure mount partition failed" {
+ exists_block_device() {
+ return 0
+ }
+ exists_key() {
+ return 0
+ }
+ cryptsetup() {
+ return 0
+ }
+ exists_partition() {
+ return 0
+ }
+ mount() {
+ 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 "ℹ️ INFO: create backup path build/test"
+ assert_line --index 5 "ℹ️ INFO: mount /dev/path/to/partday to build/test"
+ assert_line --index 6 "❌ ERROR: could not mount /dev/path/to/partday to build/test"
}
\ No newline at end of file