{
local config="$1"
local media="$2"
+ local device=
+ local key=
device=$(echo "$config" \
- | jq --raw-output ".media.\"$one_media\".device")
+ | jq --raw-output ".media.\"$media\".device")
[ "$device" != "null" ] \
- || errlog "missing device for media $one_media in $CONFIG_FILE" \
+ || errlog "missing device for media $media in $CONFIG_FILE" \
|| return $?
exists_block_device "$media" "$device" || return $?
+
+ key=$(echo "$config" \
+ | jq --raw-output ".media.\"$media\".key")
+ [ "$key" != "null" ] \
+ || errlog "missing key for media $media in $CONFIG_FILE" \
+ || return $?
}
mount_backup()
}
# bats test_tags=backupmount:mount
-@test "failure no media" {
+@test "failure missing media" {
yq() {
echo '{}'
}
}
# bats test_tags=backupmount:mount
-@test "failure no device for media day" {
+@test "failure missing device for media day" {
yq() {
echo '{
"media": {
assert_line --index 2 "❌ ERROR: block device /dev/path/to/week for week not found"
assert_line --index 3 "❌ ERROR: block device /dev/path/to/month for month not found"
assert_line --index 4 "❌ ERROR: no device found"
+}
+
+# bats test_tags=backupmount:mount
+@test "failure missing key for media day" {
+ yq() {
+ echo '{
+ "media": {
+ "day": {
+ "device": "/dev/path/to/day"
+ }
+ }
+ }'
+ }
+ exists_block_device() {
+ return 0
+ }
+
+ run main "mount"
+
+ assert_failure
+ assert_line --index 0 "⭐ START: backupmount"
+ assert_line --index 1 "❌ ERROR: missing key for media day in src/config-example.yaml"
}
\ No newline at end of file