"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: add test for 0 length files read in the way mount does
Nick Craig-Wood0386d22cc946
diff --git a/vfs/write_test.go b/vfs/write_test.goindex 6c607ec08..867326357 100644--- a/vfs/write_test.go+++ b/vfs/write_test.go@@ -2,6 +2,7 @@ package vfsimport ("context"+ "io""os""sync""testing"@@ -286,3 +287,32 @@ func TestWriteFileModTimeWithOpenWriters(t *testing.T) {assert.Equal(t, info.ModTime().Unix(), mtime.Unix())}}++func TestFileZeroLength(t *testing.T) {+ r := fstest.NewRun(t)+ defer r.Finalise()+ vfs, fh := writeHandleCreate(t, r)++ // 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)++ // read the 0 length file back in using ReadAt into a buffer+ // this simulates what mount does+ rd, err := vfs.OpenFile("file1", os.O_RDONLY, 0)+ require.NoError(t, err)++ buf := make([]byte, 1024)+ n, err := rd.ReadAt(buf, 0)+ if err != io.EOF {+ assert.NoError(t, err)+ }+ assert.Equal(t, 0, n)++ err = rd.Close()+ assert.NoError(t, err)+}