From: Bastian Dehn Date: Tue, 4 Aug 2026 14:05:06 +0000 (+0200) Subject: add test for missing backup count X-Git-Tag: v1.0.6^2~1^2~70 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=5835937b8825db3ed208f031afa5ddf658425c44;p=simple-backup.git add test for missing backup count --- diff --git a/src/backup b/src/backup index f6cb00a..7fd8036 100755 --- a/src/backup +++ b/src/backup @@ -53,6 +53,11 @@ main() [ "$backup_name" != "null" ] \ || errlog "$CONFIG_FILE missing backup_name" \ || return $? + local backup_count= + backup_count=$(echo "$config" | jq --raw-output '.backup_count') + [ "$backup_count" != "null" ] \ + || errlog "$CONFIG_FILE missing backup_count" \ + || return $? } [ "$TESTMODE" == "ON" ] && return 0 diff --git a/tests/backup_tests.bats b/tests/backup_tests.bats index 9245b2c..a39a213 100755 --- a/tests/backup_tests.bats +++ b/tests/backup_tests.bats @@ -120,4 +120,18 @@ teardown() { assert_line --index 0 "⭐ START: backup" assert_line --index 1 "❌ ERROR: src/config-example.yaml missing backup_name" +} + +@test "failure no backup count in config" { + yq() { + echo '{ + "backup_path": "path", + "backup_name": "backup" + }' + } + + run main + + assert_line --index 0 "⭐ START: backup" + assert_line --index 1 "❌ ERROR: src/config-example.yaml missing backup_count" } \ No newline at end of file