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) } }