Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

vfs: fix tests for backends which can't upload 0 length files

Nick Craig-Wood9ed81ac4510b
diff --git a/vfs/read_write_test.go b/vfs/read_write_test.go
index 3f5c0a055..e6245231c 100644
--- a/vfs/read_write_test.go
+++ b/vfs/read_write_test.go
@@ -10,6 +10,7 @@ import (
"github.com/ncw/rclone/fs"
"github.com/ncw/rclone/fstest"
+ "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -416,6 +417,10 @@ func TestRWFileHandleWriteNoWrite(t *testing.T) {
// Close the file without writing to it
err := fh.Close()
+ if errors.Cause(err) == fs.ErrorCantUploadEmptyFiles {
+ t.Logf("skipping test: %v", err)
+ return
+ }
assert.NoError(t, err)
// Create a different file (not in the cache)
diff --git a/vfs/vfs_test.go b/vfs/vfs_test.go
index 120ebebe7..359327f64 100644
--- a/vfs/vfs_test.go
+++ b/vfs/vfs_test.go
@@ -9,7 +9,9 @@ import (
"testing"
_ "github.com/ncw/rclone/backend/all" // import all the backends
+ "github.com/ncw/rclone/fs"
"github.com/ncw/rclone/fstest"
+ "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -223,7 +225,10 @@ func TestVFSOpenFile(t *testing.T) {
fd, err = vfs.OpenFile("dir/new_file.txt", os.O_WRONLY|os.O_CREATE, 0777)
require.NoError(t, err)
assert.NotNil(t, fd)
- require.NoError(t, fd.Close())
+ err = fd.Close()
+ if errors.Cause(err) != fs.ErrorCantUploadEmptyFiles {
+ require.NoError(t, err)
+ }
fd, err = vfs.OpenFile("not found/new_file.txt", os.O_WRONLY|os.O_CREATE, 0777)
assert.Equal(t, os.ErrNotExist, err)
diff --git a/vfs/write_test.go b/vfs/write_test.go
index c91150cdd..ca53eb433 100644
--- a/vfs/write_test.go
+++ b/vfs/write_test.go
@@ -9,6 +9,7 @@ import (
"github.com/ncw/rclone/fs"
"github.com/ncw/rclone/fstest"
+ "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -114,8 +115,11 @@ func TestWriteFileHandleMethods(t *testing.T) {
// it even if we don't write to it
h, err = vfs.OpenFile("file1", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0777)
require.NoError(t, err)
- assert.NoError(t, h.Close())
- checkListing(t, root, []string{"file1,0,false"})
+ err = h.Close()
+ if errors.Cause(err) != fs.ErrorCantUploadEmptyFiles {
+ assert.NoError(t, err)
+ checkListing(t, root, []string{"file1,0,false"})
+ }
// Check opening the file with O_TRUNC and writing does work
h, err = vfs.OpenFile("file1", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0777)
@@ -213,6 +217,10 @@ func TestWriteFileHandleRelease(t *testing.T) {
// Check Release closes file
err := fh.Release()
+ if errors.Cause(err) == fs.ErrorCantUploadEmptyFiles {
+ t.Logf("skipping test: %v", err)
+ return
+ }
assert.NoError(t, err)
assert.True(t, fh.closed)