]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add test without excludes
authorBastian Dehn <hhaalo@arcor.de>
Wed, 5 Aug 2026 19:20:15 +0000 (21:20 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Wed, 5 Aug 2026 19:20:15 +0000 (21:20 +0200)
src/backup
tests/backup_tests.bats

index 073e9d7c66ff9036733b4445af11579d16f9616e..4aa335c79fc5718fda3c6ad8aaedbae22b46e563 100755 (executable)
@@ -154,8 +154,10 @@ path_backup()
                || return $?
        local excludes=()
        mapfile -t excludes < <(echo "$config" \
-               | jq --raw-output ".machines.$machine.excludes[]")
-       echo "ℹ️ INFO: machine $machine; excludes ${excludes[*]}"
+               | jq --raw-output ".machines.$machine.excludes[]" \
+               2> /dev/null)
+       [ "${#excludes[@]}" -eq "0" ] \
+               || echo "ℹ️ INFO: machine $machine; excludes ${excludes[*]}"
        # TODO: config read - rsync implementation
 }
 
index 8110144cf5459e4c8993356b630ecba43d6e2c2b..4385953a1024a28d066e62ca9717244e53bf3fba 100755 (executable)
@@ -444,4 +444,37 @@ teardown() {
        assert_line --index 8 "ℹ️ INFO: machine ${LIGHTPURPLE}testpc1${RESET}; path ${YELLOW}/etc${RESET}"
        assert_line --index 9 "ℹ️ INFO: machine ${LIGHTPURPLE}testpc1${RESET}; excludes /home/user/.cache /home/user/.local"
        assert_line --index 10 "################################################################################"
+       assert_line --partial "✅ SUCCESS: backup"
+}
+
+@test "success backup machine path without excludes" {
+       yq() {
+               echo '{
+                       "backup_path": "build",
+                       "backup_name": "backup",
+                       "backup_count": 15,
+                       "machines": {
+                               "testpc1": {
+                                       "remote_user": "testuser",
+                                       "host": "remotehost",
+                                       "port": 22,
+                                       "pathes": ["/home/user"]
+                               }
+                       }
+                       }'
+       }
+       run main
+
+       assert_success
+       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 "################################################################################"
+       assert_line --index 10 "✅ SUCCESS: backup"
 }
\ No newline at end of file