vfs: convert vfs options to new style

This also
- move in use options (Opt) from vfsflags to vfscommon
- change os.FileMode to vfscommon.FileMode in parameters
- rework vfscommon.FileMode and add tests
This commit is contained in:
Nick Craig-Wood
2024-07-03 11:34:29 +01:00
parent fc1d8dafd5
commit a28287e96d
39 changed files with 408 additions and 236 deletions

View File

@ -30,7 +30,7 @@ var (
// Create a file and open it with the flags passed in
func rwHandleCreateFlags(t *testing.T, create bool, filename string, flags int) (r *fstest.Run, vfs *VFS, fh *RWFileHandle) {
opt := vfscommon.DefaultOpt
opt := vfscommon.Opt
opt.CacheMode = vfscommon.CacheModeFull
opt.WriteBack = writeBackDelay
r, vfs = newTestVFSOpt(t, &opt)
@ -634,7 +634,7 @@ func testRWFileHandleOpenTest(t *testing.T, vfs *VFS, test *openTest) {
func TestRWFileHandleOpenTests(t *testing.T) {
for _, cacheMode := range []vfscommon.CacheMode{vfscommon.CacheModeWrites, vfscommon.CacheModeFull} {
t.Run(cacheMode.String(), func(t *testing.T) {
opt := vfscommon.DefaultOpt
opt := vfscommon.Opt
opt.CacheMode = cacheMode
opt.WriteBack = writeBackDelay
_, vfs := newTestVFSOpt(t, &opt)
@ -685,7 +685,7 @@ func TestRWFileModTimeWithOpenWriters(t *testing.T) {
}
func TestRWCacheRename(t *testing.T) {
opt := vfscommon.DefaultOpt
opt := vfscommon.Opt
opt.CacheMode = vfscommon.CacheModeFull
opt.WriteBack = writeBackDelay
r, vfs := newTestVFSOpt(t, &opt)
@ -719,7 +719,7 @@ func TestRWCacheRename(t *testing.T) {
//
// See: https://github.com/rclone/rclone/issues/6053
func TestRWCacheUpdate(t *testing.T) {
opt := vfscommon.DefaultOpt
opt := vfscommon.Opt
opt.CacheMode = vfscommon.CacheModeFull
opt.WriteBack = writeBackDelay
opt.DirCacheTime = fs.Duration(100 * time.Millisecond)