onedrive: fix integration tests after precision change

We changed the precision of the onedrive personal backend in
c053429b9c from 1mS to 1S.

However the tests did not get updated. This changes the time tests to
use `fstest.AssertTimeEqualWithPrecision` which compares with
precision so hopefully won't break again.
This commit is contained in:
Nick Craig-Wood 2024-11-12 13:05:57 +00:00
parent e50f995d87
commit f639cd9c78

View file

@ -215,11 +215,11 @@ func (f *Fs) TestDirectoryMetadata(t *testing.T, r *fstest.Run) {
compareDirMeta(expectedMeta, actualMeta, false) compareDirMeta(expectedMeta, actualMeta, false)
// modtime // modtime
assert.Equal(t, t1.Truncate(f.Precision()), newDst.ModTime(ctx)) fstest.AssertTimeEqualWithPrecision(t, newDst.Remote(), t1, newDst.ModTime(ctx), f.Precision())
// try changing it and re-check it // try changing it and re-check it
newDst, err = operations.SetDirModTime(ctx, f, newDst, "", t2) newDst, err = operations.SetDirModTime(ctx, f, newDst, "", t2)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, t2.Truncate(f.Precision()), newDst.ModTime(ctx)) fstest.AssertTimeEqualWithPrecision(t, newDst.Remote(), t2, newDst.ModTime(ctx), f.Precision())
// ensure that f.DirSetModTime also works // ensure that f.DirSetModTime also works
err = f.DirSetModTime(ctx, "subdir", t3) err = f.DirSetModTime(ctx, "subdir", t3)
assert.NoError(t, err) assert.NoError(t, err)
@ -227,7 +227,7 @@ func (f *Fs) TestDirectoryMetadata(t *testing.T, r *fstest.Run) {
assert.NoError(t, err) assert.NoError(t, err)
entries.ForDir(func(dir fs.Directory) { entries.ForDir(func(dir fs.Directory) {
if dir.Remote() == "subdir" { if dir.Remote() == "subdir" {
assert.True(t, t3.Truncate(f.Precision()).Equal(dir.ModTime(ctx)), fmt.Sprintf("got %v", dir.ModTime(ctx))) fstest.AssertTimeEqualWithPrecision(t, dir.Remote(), t3, dir.ModTime(ctx), f.Precision())
} }
}) })