From: Bastian Dehn Date: Wed, 5 Aug 2026 18:52:00 +0000 (+0200) Subject: add no host error test X-Git-Tag: v1.0.6^2~1^2~48 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=b42ebacc8a2b728ee876955ebb660cc46881dc09;p=simple-backup.git add no host error test --- diff --git a/src/backup b/src/backup index 0a5d574..c1c0237 100755 --- a/src/backup +++ b/src/backup @@ -135,12 +135,18 @@ path_backup() local path="$3" local full_backup_path="$4" local remote_user= + local host= remote_user=$(echo "$config" \ | jq --raw-output ".machines.$machine.remote_user") [ "$remote_user" != "null" ] \ || errlog "no remote user for $machine" \ || return $? + host=$(echo "$config" \ + | jq --raw-output ".machines.$machine.host") + [ "$host" != "null" ] \ + || errlog "no host for $machine" \ + || return $? # TODO: config read - rsync implementation } diff --git a/tests/backup_tests.bats b/tests/backup_tests.bats index 49c6082..ce2ed1c 100755 --- a/tests/backup_tests.bats +++ b/tests/backup_tests.bats @@ -363,4 +363,34 @@ teardown() { assert_line --index 7 "################################################################################" assert_line --index 8 "ℹ️ INFO: machine ${LIGHTPURPLE}testpc1${RESET}; path ${YELLOW}/home/user${RESET}" assert_line --index 9 "❌ ERROR: no remote user for testpc1" +} + +@test "failure backup machine path no host" { + yq() { + echo '{ + "backup_path": "build", + "backup_name": "backup", + "backup_count": 15, + "machines": { + "testpc1": { + "remote_user": "testuser", + "pathes": ["/home/user"] + } + } + }' + } + + run main + + assert_failure + assert_line --index 0 "⭐ START: backup" + assert_line --index 1 "ℹ️ INFO: backup path build" + assert_line --index 2 "ℹ️ INFO: backup name backup" + assert_line --index 3 "ℹ️ INFO: backup count 15" + assert_line --index 4 "ℹ️ INFO: backup folder 2000-01-01_01_backup" + assert_line --index 5 "ℹ️ INFO: create folder build/2000-01-01_01_backup" + assert_line --index 6 "ℹ️ INFO: create directory build/2000-01-01_01_backup/testpc1" + assert_line --index 7 "################################################################################" + assert_line --index 8 "ℹ️ INFO: machine ${LIGHTPURPLE}testpc1${RESET}; path ${YELLOW}/home/user${RESET}" + assert_line --index 9 "❌ ERROR: no host for testpc1" } \ No newline at end of file