]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
check machine path
authorBastian Dehn <hhaalo@arcor.de>
Sat, 15 Aug 2026 12:48:58 +0000 (14:48 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 15 Aug 2026 12:48:58 +0000 (14:48 +0200)
src/restore
tests/restore_tests.bats

index 8a181be73f3a2ed0df63dc99c0ef441181c1f331..e418cf2ccdf9b4cb74802af255c4c1b15cb861fd 100755 (executable)
@@ -102,6 +102,9 @@ restore()
        [ -d "$backup_path/$backup_dir" ] \
                || errlog "directory $backup_path/$backup_dir not exists" \
                || return $?
+       [ -d "$backup_path/$backup_dir/$machine" ] \
+               || errlog "directory $backup_path/$backup_dir/$machine not exists" \
+               || return $?
 }
 
 main()
index cf3913eb27a34d370288293af3f984f045335a52..ff161f7f3c91ae9da753957d587f9ac3f4050e4b 100755 (executable)
@@ -279,4 +279,17 @@ teardown() {
        assert_line --index 1 "ℹ️ INFO: backup path build/test"
        assert_line --index 2 "ℹ️ INFO: backup name backup"
        assert_line --index 3 "❌ ERROR: directory build/test/2000-01-01_01_backup not exists"
+}
+
+# bats test_tags=backup:pathcheck
+@test "failure no backup directory machine" {
+       mkdir --parents "build/test/2000-01-01_01_backup"
+
+       run main -d "2000-01-01" -n "01" -r "testpc1.example.com" -p "/testpath"
+
+       assert_failure
+       assert_line --index 0 "⭐ START: restore"
+       assert_line --index 1 "ℹ️ INFO: backup path build/test"
+       assert_line --index 2 "ℹ️ INFO: backup name backup"
+       assert_line --index 3 "❌ ERROR: directory build/test/2000-01-01_01_backup/testpc1.example.com not exists"
 }
\ No newline at end of file