From 4f05ece39edc4918a5f2542a445fb436459c80e4 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Thu, 21 Oct 2021 16:57:18 +0200 Subject: [PATCH] test: fix touchdir test on backends without modtime support --- fs/operations/operations_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.go index cdfe6df0d..719f2e8c5 100644 --- a/fs/operations/operations_test.go +++ b/fs/operations/operations_test.go @@ -34,6 +34,7 @@ import ( "testing" "time" + "github.com/pkg/errors" _ "github.com/rclone/rclone/backend/all" // import all backends "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/accounting" @@ -1579,6 +1580,10 @@ func TestTouchDir(t *testing.T) { r := fstest.NewRun(t) defer r.Finalise() + if r.Fremote.Precision() == fs.ModTimeNotSupported { + t.Skip("Skipping test as remote does not support modtime") + } + file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1) file2 := r.WriteBoth(ctx, "empty space", "-", t2) file3 := r.WriteBoth(ctx, "sub dir/potato3", "hello", t2) @@ -1587,8 +1592,13 @@ func TestTouchDir(t *testing.T) { timeValue := time.Date(2010, 9, 8, 7, 6, 5, 4, time.UTC) err := operations.TouchDir(ctx, r.Fremote, timeValue, true) require.NoError(t, err) - file1.ModTime = timeValue - file2.ModTime = timeValue - file3.ModTime = timeValue - fstest.CheckItems(t, r.Fremote, file1, file2, file3) + if accounting.Stats(ctx).GetErrors() != 0 { + err = errors.Cause(accounting.Stats(ctx).GetLastError()) + require.True(t, err == fs.ErrorCantSetModTime || err == fs.ErrorCantSetModTimeWithoutDelete) + } else { + file1.ModTime = timeValue + file2.ModTime = timeValue + file3.ModTime = timeValue + fstest.CheckItems(t, r.Fremote, file1, file2, file3) + } }