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