fstests: In TestFsPutError reliably provoke test failure

This change to go1.11 causes the TestFsPutError test to fail

https://go-review.googlesource.com/c/go/+/114316

This is because it now passes the half written file to the backend
whereas it didn't previously because of the buffering.

In this commit the size of the data written was increased to 5k from
50 bytes to provoke the test failure under go1.10 also.
This commit is contained in:
Nick Craig-Wood 2018-08-16 15:52:15 +01:00
parent 751bfd456f
commit 58339a5cb6
1 changed files with 4 additions and 3 deletions

View File

@ -382,13 +382,14 @@ func Run(t *testing.T, opt *Opt) {
t.Run("TestFsPutError", func(t *testing.T) {
skipIfNotOk(t)
// Read 50 bytes then produce an error
contents := fstest.RandomString(50)
const N = 5 * 1024
// Read N bytes then produce an error
contents := fstest.RandomString(N)
buf := bytes.NewBufferString(contents)
er := &errorReader{errors.New("potato")}
in := io.MultiReader(buf, er)
obji := object.NewStaticObjectInfo(file2.Path, file2.ModTime, 100, true, nil, nil)
obji := object.NewStaticObjectInfo(file2.Path, file2.ModTime, 2*N, true, nil, nil)
_, err := remote.Put(in, obji)
// assert.Nil(t, obj) - FIXME some remotes return the object even on nil
assert.NotNil(t, err)