local backup_path=
backup_path=$(echo "$config" | jq --raw-output '.backup_path')
[ "$backup_path" != "null" ] \
- || errlog "$CONFIG_FILE missing backup_path" \
+ || errlog "missing backup_path in $CONFIG_FILE" \
|| return $?
echo "ℹ️ INFO: backup path $backup_path"
}
local backup_name=
backup_name=$(echo "$config" | jq --raw-output '.backup_name')
[ "$backup_name" != "null" ] \
- || errlog "$CONFIG_FILE missing backup_name" \
+ || errlog "missing backup_name in $CONFIG_FILE" \
|| return $?
echo "ℹ️ INFO: backup name $backup_name"
}
| jq --raw-output ".backup_path")
backup_name=$(echo "$config" \
| jq --raw-output ".backup_name")
+ echo "$config" \
+ | jq --exit-status ".machines | has(\"$machine\")" > /dev/null \
+ || errlog "missing machine $machine in $CONFIG_FILE" \
+ || return $?
remote_user=$(echo "$config" \
| jq --raw-output ".machines.\"$machine\".remote_user")
[ "$remote_user" != "null" ] \
assert_failure
assert_line --index 0 "⭐ START: restore"
- assert_line --index 1 "❌ ERROR: src/config-example.yaml missing backup_path"
+ assert_line --index 1 "❌ ERROR: missing backup_path in src/config-example.yaml"
}
# bats test_tags=restore:start,restore:config
assert_failure
assert_line --index 0 "⭐ START: restore"
assert_line --index 1 "ℹ️ INFO: backup path path"
- assert_line --index 2 "❌ ERROR: src/config-example.yaml missing backup_name"
+ assert_line --index 2 "❌ ERROR: missing backup_name in src/config-example.yaml"
}
# bats test_tags=restore:start,restore:config
assert_line --index 3 "❌ ERROR: missing path (-p)"
}
+# bats test_tags=restore:config
+@test "failure config missing machine" {
+ yq() {
+ echo '{
+ "backup_path": "build/test",
+ "backup_name": "backup",
+ "machines": {
+ "testpc2.example.com": {}
+ }
+ }'
+ }
+
+ run main -d "2000-01-01" -n "01" -r "testpc1.example.com" -p "/testpath"
+
+ assert_failure
+ assert_line --index 0 "⭐ START: restore"
+ assert_line --index 1 "ℹ️ INFO: backup path build/test"
+ assert_line --index 2 "ℹ️ INFO: backup name backup"
+ assert_line --index 3 "❌ ERROR: missing machine testpc1.example.com in src/config-example.yaml"
+}
+
# bats test_tags=restore:config
@test "failure config missing remote user" {
yq() {