test_all: add the vfs tests to the integration tests
Fix failing tests for some remotes
This commit is contained in:
parent
14ef4437e5
commit
ac7e1dbf62
6 changed files with 57 additions and 4 deletions
|
@ -8,6 +8,7 @@ tests:
|
||||||
- path: fs/sync
|
- path: fs/sync
|
||||||
subdir: true
|
subdir: true
|
||||||
fastlist: true
|
fastlist: true
|
||||||
|
- path: vfs
|
||||||
backends:
|
backends:
|
||||||
# - backend: "amazonclouddrive"
|
# - backend: "amazonclouddrive"
|
||||||
# remote: "TestAmazonCloudDrive:"
|
# remote: "TestAmazonCloudDrive:"
|
||||||
|
|
|
@ -468,6 +468,12 @@ func TestDirRemoveName(t *testing.T) {
|
||||||
func TestDirRename(t *testing.T) {
|
func TestDirRename(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
defer r.Finalise()
|
||||||
|
|
||||||
|
features := r.Fremote.Features()
|
||||||
|
if features.DirMove == nil && features.Move == nil && features.Copy == nil {
|
||||||
|
return // skip as can't rename directories
|
||||||
|
}
|
||||||
|
|
||||||
vfs, dir, file1 := dirCreate(t, r)
|
vfs, dir, file1 := dirCreate(t, r)
|
||||||
file3 := r.WriteObject("dir/file3", "file3 contents!", t1)
|
file3 := r.WriteObject("dir/file3", "file3 contents!", t1)
|
||||||
fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{file1, file3}, []string{"dir"}, r.Fremote.Precision())
|
fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{file1, file3}, []string{"dir"}, r.Fremote.Precision())
|
||||||
|
|
|
@ -77,6 +77,9 @@ func TestFileMethods(t *testing.T) {
|
||||||
|
|
||||||
func TestFileSetModTime(t *testing.T) {
|
func TestFileSetModTime(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
|
if !canSetModTime(t, r) {
|
||||||
|
return
|
||||||
|
}
|
||||||
defer r.Finalise()
|
defer r.Finalise()
|
||||||
vfs, file, file1 := fileCreate(t, r)
|
vfs, file, file1 := fileCreate(t, r)
|
||||||
|
|
||||||
|
|
|
@ -574,6 +574,9 @@ func TestRWFileHandleOpenTests(t *testing.T) {
|
||||||
func TestRWFileModTimeWithOpenWriters(t *testing.T) {
|
func TestRWFileModTimeWithOpenWriters(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
defer r.Finalise()
|
||||||
|
if !canSetModTime(t, r) {
|
||||||
|
return
|
||||||
|
}
|
||||||
vfs, fh := rwHandleCreateWriteOnly(t, r)
|
vfs, fh := rwHandleCreateWriteOnly(t, r)
|
||||||
|
|
||||||
mtime := time.Date(2012, time.November, 18, 17, 32, 31, 0, time.UTC)
|
mtime := time.Date(2012, time.November, 18, 17, 32, 31, 0, time.UTC)
|
||||||
|
@ -590,6 +593,8 @@ func TestRWFileModTimeWithOpenWriters(t *testing.T) {
|
||||||
info, err := vfs.Stat("file1")
|
info, err := vfs.Stat("file1")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// avoid errors because of timezone differences
|
if r.Fremote.Precision() != fs.ModTimeNotSupported {
|
||||||
assert.Equal(t, info.ModTime().Unix(), mtime.Unix())
|
// avoid errors because of timezone differences
|
||||||
|
assert.Equal(t, info.ModTime().Unix(), mtime.Unix())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,10 @@ func TestVFSOpenFile(t *testing.T) {
|
||||||
func TestVFSRename(t *testing.T) {
|
func TestVFSRename(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
defer r.Finalise()
|
||||||
|
features := r.Fremote.Features()
|
||||||
|
if features.Move == nil && features.Copy == nil {
|
||||||
|
return // skip as can't rename files
|
||||||
|
}
|
||||||
vfs := New(r.Fremote, nil)
|
vfs := New(r.Fremote, nil)
|
||||||
|
|
||||||
file1 := r.WriteObject("dir/file2", "file2 contents", t2)
|
file1 := r.WriteObject("dir/file2", "file2 contents", t2)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package vfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -220,10 +221,41 @@ func TestWriteFileHandleRelease(t *testing.T) {
|
||||||
assert.True(t, fh.closed)
|
assert.True(t, fh.closed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
canSetModTimeOnce sync.Once
|
||||||
|
canSetModTimeValue = true
|
||||||
|
)
|
||||||
|
|
||||||
|
// returns whether the remote can set modtime
|
||||||
|
func canSetModTime(t *testing.T, r *fstest.Run) bool {
|
||||||
|
canSetModTimeOnce.Do(func() {
|
||||||
|
mtime1 := time.Date(2008, time.November, 18, 17, 32, 31, 0, time.UTC)
|
||||||
|
_ = r.WriteObject("time_test", "stuff", mtime1)
|
||||||
|
obj, err := r.Fremote.NewObject("time_test")
|
||||||
|
require.NoError(t, err)
|
||||||
|
mtime2 := time.Date(2009, time.November, 18, 17, 32, 31, 0, time.UTC)
|
||||||
|
err = obj.SetModTime(mtime2)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
canSetModTimeValue = true
|
||||||
|
case fs.ErrorCantSetModTime, fs.ErrorCantSetModTimeWithoutDelete:
|
||||||
|
canSetModTimeValue = false
|
||||||
|
default:
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
require.NoError(t, obj.Remove())
|
||||||
|
fs.Debugf(nil, "Can set mod time: %v", canSetModTimeValue)
|
||||||
|
})
|
||||||
|
return canSetModTimeValue
|
||||||
|
}
|
||||||
|
|
||||||
// tests mod time on open files
|
// tests mod time on open files
|
||||||
func TestWriteFileModTimeWithOpenWriters(t *testing.T) {
|
func TestWriteFileModTimeWithOpenWriters(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
defer r.Finalise()
|
||||||
|
if !canSetModTime(t, r) {
|
||||||
|
return
|
||||||
|
}
|
||||||
vfs, fh := writeHandleCreate(t, r)
|
vfs, fh := writeHandleCreate(t, r)
|
||||||
|
|
||||||
mtime := time.Date(2012, time.November, 18, 17, 32, 31, 0, time.UTC)
|
mtime := time.Date(2012, time.November, 18, 17, 32, 31, 0, time.UTC)
|
||||||
|
@ -240,6 +272,8 @@ func TestWriteFileModTimeWithOpenWriters(t *testing.T) {
|
||||||
info, err := vfs.Stat("file1")
|
info, err := vfs.Stat("file1")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// avoid errors because of timezone differences
|
if r.Fremote.Precision() != fs.ModTimeNotSupported {
|
||||||
assert.Equal(t, info.ModTime().Unix(), mtime.Unix())
|
// avoid errors because of timezone differences
|
||||||
|
assert.Equal(t, info.ModTime().Unix(), mtime.Unix())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue