🧪 fstest: fix time tests on Windows and add convenience methods to check local and remote fs with precision

Previously only the fs being checked on gets passed to
GetModifyWindow(). However, in most tests, the test files are
generated in the local fs and transferred to the remote fs. So the
local fs time precision has to be taken into account.

This meant that on Windows the time tests failed because the
local fs has a time precision of 100ns. Checking remote items uploaded
from local fs on Windows also requires a modify window of 100ns.
This commit is contained in:
database64128 2021-11-09 19:43:36 +08:00 committed by GitHub
parent 9beb0677e4
commit a7a8372976
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 410 additions and 410 deletions

View file

@ -24,7 +24,7 @@ func fileCreate(t *testing.T, mode vfscommon.CacheMode) (r *fstest.Run, vfs *VFS
r, vfs, cleanup = newTestVFSOpt(t, &opt)
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
fstest.CheckItems(t, r.Fremote, file1)
r.CheckRemoteItems(t, file1)
node, err := vfs.Stat("dir/file1")
require.NoError(t, err)
@ -137,7 +137,7 @@ func testFileSetModTime(t *testing.T, cacheMode vfscommon.CacheMode, open bool,
}
file1 = fstest.NewItem(file1.Path, contents, t2)
fstest.CheckItems(t, r.Fremote, file1)
r.CheckRemoteItems(t, file1)
vfs.Opt.ReadOnly = true
err = file.SetModTime(t2)
@ -255,7 +255,7 @@ func TestFileRemove(t *testing.T) {
err := file.Remove()
require.NoError(t, err)
fstest.CheckItems(t, r.Fremote)
r.CheckRemoteItems(t)
vfs.Opt.ReadOnly = true
err = file.Remove()
@ -269,7 +269,7 @@ func TestFileRemoveAll(t *testing.T) {
err := file.RemoveAll()
require.NoError(t, err)
fstest.CheckItems(t, r.Fremote)
r.CheckRemoteItems(t)
vfs.Opt.ReadOnly = true
err = file.RemoveAll()
@ -340,14 +340,14 @@ func testFileRename(t *testing.T, mode vfscommon.CacheMode, inCache bool, forceC
dir := file.Dir()
// start with "dir/file1"
fstest.CheckItems(t, r.Fremote, item)
r.CheckRemoteItems(t, item)
// rename file to "newLeaf"
err = dir.Rename("file1", "newLeaf", rootDir)
require.NoError(t, err)
item.Path = "newLeaf"
fstest.CheckItems(t, r.Fremote, item)
r.CheckRemoteItems(t, item)
// check file in cache
if inCache {
@ -363,7 +363,7 @@ func testFileRename(t *testing.T, mode vfscommon.CacheMode, inCache bool, forceC
require.NoError(t, err)
item.Path = "dir/file1"
fstest.CheckItems(t, r.Fremote, item)
r.CheckRemoteItems(t, item)
// check file in cache
if inCache {