]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add failure backup path not exists
authorBastian Dehn <hhaalo@arcor.de>
Sat, 29 Aug 2026 06:19:44 +0000 (08:19 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 29 Aug 2026 06:21:11 +0000 (08:21 +0200)
src/backup
tests/backup_tests.bats

index 0d122c56beb779bbbb5b175692b8d8eef0825b38..59af146f243afbb7b0d5d0858ba9deb0871570da 100755 (executable)
@@ -95,6 +95,9 @@ exists_backup_path()
        [ "$backup_path" != "null" ] \
                || errlog "$CONFIG_FILE missing backup_path" \
                || return $?
+       [ -d "$backup_path" ] \
+               || errlog "backup path $backup_path not exists" \
+               || return $?
        echo "ℹ️ INFO: backup path $backup_path"
 }
 
index 1001b6fe5a57ef2024eb830df883f644a96af7d6..f4b945a0ca1264b3eaffd85ba839729efcd36bc9 100755 (executable)
@@ -9,6 +9,7 @@ setup() {
        export RSYNC_LOG="build/test/rsync.log"
        export RSYNC_LOG_RUNS="0"
        source src/backup
+       mkdir --parents "build/test"
        get_date() {
                echo "2000-01-01"
        }
@@ -143,14 +144,14 @@ teardown() {
 # bats test_tags=backup:start,backup:config
 @test "failure no backup name in config" {
        yq() {
-               echo '{"backup_path": "path"}'
+               echo '{"backup_path": "build/test"}'
        }
 
        run main
 
        assert_failure
        assert_line --index 0 "⭐ START: backup"
-       assert_line --index 1 "ℹ️ INFO: backup path path"
+       assert_line --index 1 "ℹ️ INFO: backup path build/test"
        assert_line --index 2 "❌ ERROR: src/config-example.yaml missing backup_name"
 }
 
@@ -158,7 +159,7 @@ teardown() {
 @test "failure no backup count in config" {
        yq() {
                echo '{
-                       "backup_path": "path",
+                       "backup_path": "build/test",
                        "backup_name": "backup"
                        }'
        }
@@ -167,7 +168,7 @@ teardown() {
 
        assert_failure
        assert_line --index 0 "⭐ START: backup"
-       assert_line --index 1 "ℹ️ INFO: backup path path"
+       assert_line --index 1 "ℹ️ INFO: backup path build/test"
        assert_line --index 2 "ℹ️ INFO: backup name backup"
        assert_line --index 3 "❌ ERROR: src/config-example.yaml missing backup_count"
 }
@@ -176,7 +177,7 @@ teardown() {
 @test "failure no machines in config" {
        yq() {
                echo '{
-                       "backup_path": "path",
+                       "backup_path": "build/test",
                        "backup_name": "backup",
                        "backup_count": 15
                        }'
@@ -186,12 +187,23 @@ teardown() {
 
        assert_failure
        assert_line --index 0 "⭐ START: backup"
-       assert_line --index 1 "ℹ️ INFO: backup path path"
+       assert_line --index 1 "ℹ️ INFO: backup path build/test"
        assert_line --index 2 "ℹ️ INFO: backup name backup"
        assert_line --index 3 "ℹ️ INFO: backup count 15"
        assert_line --index 4 "❌ ERROR: src/config-example.yaml missing machines"
 }
 
+# bats test_tags=backup:info
+@test "failed backup path not exists" {
+       rmdir "build/test"
+
+       run main
+
+       assert_failure
+       assert_line --index 0 "⭐ START: backup"
+       assert_line --index 1 "❌ ERROR: backup path build/test not exists"
+}
+
 # bats test_tags=backup:info
 @test "success info backup count" {
        create_backup_dir() {
@@ -203,6 +215,9 @@ teardown() {
        cleanup_old_backups() {
                :
        }
+       check_backup_date() {
+               :
+       }
 
        run main
 
@@ -231,6 +246,9 @@ teardown() {
        cleanup_old_backups() {
                :
        }
+       check_backup_date() {
+               :
+       }
 
        run main
 
@@ -257,6 +275,9 @@ teardown() {
        cleanup_old_backups() {
                :
        }
+       check_backup_date() {
+               :
+       }
 
        run main