Add scheduled rsync copy jobs

This commit is contained in:
Mikei386
2026-06-15 17:15:27 +02:00
parent 2abfc8eb26
commit 6c795fd97d
15 changed files with 524 additions and 59 deletions
+25
View File
@@ -0,0 +1,25 @@
package rsync
import (
"slices"
"testing"
"git.casaderoll.de/michael/urbm/internal/model"
)
func TestArgumentsUseExplicitSafeOptions(t *testing.T) {
job := model.Job{Sources: []model.Source{{Path: "/mnt/user/data"}}, Excludes: []string{"*.tmp"}, Rsync: model.RsyncOptions{Target: "/mnt/remotes/backup", Delete: true, PreservePermissions: true}}
args := Arguments(job)
for _, expected := range []string{"--recursive", "--delete-delay", "--perms", "--exclude", "*.tmp", "--", "/mnt/user/data", "/mnt/remotes/backup/"} {
if !slices.Contains(args, expected) {
t.Fatalf("missing %q in %#v", expected, args)
}
}
}
func TestParseProgress(t *testing.T) {
progress, ok := parseProgress(" 1,234,567 42% 12.34MB/s 0:00:05")
if !ok || progress.Bytes != 1234567 || progress.Percent != 42 {
t.Fatalf("progress = %#v, %v", progress, ok)
}
}