fstests: add test for 0 sized streaming upload

This commit is contained in:
Nick Craig-Wood 2020-01-05 11:23:39 +00:00
parent eb10ac346f
commit ad2bb86d8c

View file

@ -18,6 +18,7 @@ import (
"path/filepath" "path/filepath"
"reflect" "reflect"
"sort" "sort"
"strconv"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -1571,6 +1572,8 @@ func Run(t *testing.T, opt *Opt) {
t.Skip("FS has no PutStream interface") t.Skip("FS has no PutStream interface")
} }
for _, contentSize := range []int{0, 100} {
t.Run(strconv.Itoa(contentSize), func(t *testing.T) {
file := fstest.Item{ file := fstest.Item{
ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"), ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"),
Path: "piped data.txt", Path: "piped data.txt",
@ -1581,7 +1584,6 @@ func Run(t *testing.T, opt *Opt) {
err error err error
obj fs.Object obj fs.Object
uploadHash *hash.MultiHasher uploadHash *hash.MultiHasher
contentSize = 100
) )
retry(t, "PutStream", func() error { retry(t, "PutStream", func() error {
contents := random.String(contentSize) contents := random.String(contentSize)
@ -1602,6 +1604,8 @@ func Run(t *testing.T, opt *Opt) {
file.Check(t, obj, remote.Precision()) file.Check(t, obj, remote.Precision())
require.NoError(t, obj.Remove(ctx)) require.NoError(t, obj.Remove(ctx))
}) })
}
})
// TestInternal calls InternalTest() on the Fs // TestInternal calls InternalTest() on the Fs
t.Run("Internal", func(t *testing.T) { t.Run("Internal", func(t *testing.T) {