fstests: add integration test for uploading empty files

This tests a remote can upload empty files.  If the remote can't
upload empty files it should return fs.ErrorCantUploadEmptyFiles.
This commit is contained in:
Nick Craig-Wood 2019-06-30 18:31:58 +01:00
parent 6ff7b2eaab
commit 3245c0ae0d

View file

@ -189,6 +189,9 @@ func testPutLarge(t *testing.T, f fs.Fs, file *fstest.Item) {
obji := object.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil) obji := object.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil)
obj, err = f.Put(context.Background(), in, obji) obj, err = f.Put(context.Background(), in, obji)
if file.Size == 0 && err == fs.ErrorCantUploadEmptyFiles {
t.Skip("Can't upload zero length files")
}
return err return err
}) })
file.Hashes = uploadHash.Sums() file.Hashes = uploadHash.Sums()
@ -675,6 +678,16 @@ func Run(t *testing.T, opt *Opt) {
} }
}) })
t.Run("FsPutZeroLength", func(t *testing.T) {
skipIfNotOk(t)
testPutLarge(t, remote, &fstest.Item{
ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"),
Path: fmt.Sprintf("zero-length-file"),
Size: int64(0),
})
})
t.Run("FsOpenWriterAt", func(t *testing.T) { t.Run("FsOpenWriterAt", func(t *testing.T) {
skipIfNotOk(t) skipIfNotOk(t)
openWriterAt := remote.Features().OpenWriterAt openWriterAt := remote.Features().OpenWriterAt