From be39e9991892bd27a41c59817373c4c260236b27 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 1 Mar 2024 10:56:48 +0000 Subject: [PATCH] sync: fix TestMoveEmptyDirectories so they work on backends which don't support DirModTimes --- fs/sync/sync_test.go | 3 +-- fstest/fstest.go | 4 ++++ fstest/run.go | 4 +--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/sync/sync_test.go b/fs/sync/sync_test.go index c0728cf06..1f21806fc 100644 --- a/fs/sync/sync_test.go +++ b/fs/sync/sync_test.go @@ -340,8 +340,7 @@ func TestMoveEmptyDirectories(t *testing.T) { // Note that "sub dir" mod time is updated when file1 is deleted from it // So check it more manually got := fstest.NewDirectory(ctx, t, r.Fremote, "sub dir") - gotT := got.ModTime(ctx) - fstest.AssertTimeEqualWithPrecision(t, subDir.Remote(), subDirT, gotT, fs.GetModifyWindow(ctx, r.Fremote, r.Flocal)) + fstest.CheckDirModTime(ctx, t, r.Fremote, got, subDirT) } // Test sync empty directories diff --git a/fstest/fstest.go b/fstest/fstest.go index f4e7a97f2..ebea012c7 100644 --- a/fstest/fstest.go +++ b/fstest/fstest.go @@ -602,6 +602,10 @@ func CheckEntryMetadata(ctx context.Context, t *testing.T, f fs.Fs, entry fs.Dir // CheckDirModTime checks the modtime on the directory func CheckDirModTime(ctx context.Context, t *testing.T, f fs.Fs, dir fs.Directory, wantT time.Time) { + if f.Features().DirSetModTime == nil && f.Features().MkdirMetadata == nil { + fs.Debugf(f, "Skipping modtime test as remote does not support DirSetModTime or MkdirMetadata") + return + } gotT := dir.ModTime(ctx) AssertTimeEqualWithPrecision(t, dir.Remote(), wantT, gotT, f.Precision()) } diff --git a/fstest/run.go b/fstest/run.go index dbb794337..df95395c6 100644 --- a/fstest/run.go +++ b/fstest/run.go @@ -370,9 +370,7 @@ func (r *Run) CheckDirectoryModTimes(t *testing.T, names ...string) { for _, name := range names { wantT := NewDirectory(ctx, t, r.Flocal, name).ModTime(ctx) got := NewDirectory(ctx, t, r.Fremote, name) - gotT := got.ModTime(ctx) - fs.Debugf(r.Fremote, "Testing directory mod time of %q: wantT=%v, gotT=%v", name, wantT, gotT) - AssertTimeEqualWithPrecision(t, got.Remote(), wantT, gotT, fs.GetModifyWindow(ctx, r.Fremote, r.Flocal)) + CheckDirModTime(ctx, t, r.Fremote, got, wantT) } }