local media="$2"
local device=
local key=
+ local volume=
device=$(echo "$config" \
| jq --raw-output ".media.\"$media\".device")
|| errlog "missing key for media $media in $CONFIG_FILE" \
|| return $?
exists_key "$media" "$key" || return $?
+ echo "ℹ️ INFO: use key $key"
+
+ volume=$(echo "$config" \
+ | jq --raw-output ".media.\"$media\".volume")
+ [ "$volume" != "null" ] \
+ || errlog "missing volume in $CONFIG_FILE" \
+ || return $?
}
mount_backup()
assert_line --index 0 "⭐ START: backupmount"
assert_line --index 1 "ℹ️ INFO: media day with device /dev/path/to/day found"
assert_line --index 2 "❌ ERROR: key notexistskey for media day not exists"
+}
+
+# bats test_tags=backupmount:mount
+@test "failure missing volume for media day" {
+ yq() {
+ echo '{
+ "media": {
+ "day": {
+ "device": "/dev/path/to/day",
+ "key": "/path/to/key"
+ }
+ }
+ }'
+ }
+ exists_block_device() {
+ return 0
+ }
+ exists_key() {
+ return 0
+ }
+
+ 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/key"
+ assert_line --index 3 "❌ ERROR: missing volume in src/config-example.yaml"
}
\ No newline at end of file