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

index 1aab725fe1b32ef3e2e5607de606a21e4bf52897..501f7fcc2c3f353aaef99429fa074e40dade4ec2 100755 (executable)
@@ -170,10 +170,10 @@ path_backup()
        for exclude in "${excludes[@]}"; do
                rsyncargs+=("--exclude=\"$exclude\"")
        done
-       rsyncargs+=("--rsh=ssh -p $port")
+       rsyncargs+=("--rsh=\"ssh -p $port\"")
        local hostpath="$remote_user@$host:$path"
        rsyncargs+=("$hostpath")
-       rsyncargs+=("$backup_path/$machine")
+       rsyncargs+=("$full_backup_path")
 
        rsync "${rsyncargs[@]}"
 }
index 650100b1f573acc65e29ea24609fd72acf1e2f18..531f31d13411c2b46df6420700b93eff643ad46c 100755 (executable)
@@ -483,7 +483,9 @@ teardown() {
 }
 
 @test "success backup machine path rsync parameters" {
+       local runonce="0"
        rsync() {
+               [ "$runonce" == "1" ] && return 0
                [ "$1" == "--archive" ]; shift
                [ "$1" == "--verbose" ]; shift
                [ "$1" == "--sparse" ]; shift
@@ -495,7 +497,31 @@ teardown() {
                [ "$1" == "--exclude=\"/home/user/.local\"" ]; shift
                [ "$1" == "--rsh=\"ssh -p 22\"" ]; shift
                [ "$1" == "backupuser@www.example.com:/etc" ]; shift
-               [ "$1" == "build/2000-01-01_01_backup/testpc1" ]; shift
+               [ "$1" == "build/2000-01-01_01_backup/testpc1" ]
+               runonce="1"
+       }
+       run main
+
+       assert_success
+       assert_line --index 0 "⭐ START: backup"
+       assert_line --partial "✅ SUCCESS: backup"
+}
+
+@test "success backup machine path rsync parameters without excludes" {
+       local runonce="0"
+       rsync() {
+               [ "$runonce" == "1" ] && return 0
+               [ "$1" == "--archive" ]; shift
+               [ "$1" == "--verbose" ]; shift
+               [ "$1" == "--sparse" ]; shift
+               [ "$1" == "--acls" ]; shift
+               [ "$1" == "--hard-links" ]; shift
+               [ "$1" == "--relative" ]; shift
+               [ "$1" == "--human-readable" ]; shift
+               [ "$1" == "--rsh=\"ssh -p 22\"" ]; shift
+               [ "$1" == "backupuser@www.example.com:/etc" ]; shift
+               [ "$1" == "build/2000-01-01_01_backup/testpc1" ]
+               runonce="1"
        }
        run main