func testPut(t *testing.T, file *fstest.Item) { again: buf := bytes.NewBufferString(fstest.RandomString(100)) hash := fs.NewMultiHasher() in := io.TeeReader(buf, hash) tries := 1 const maxTries = 10 file.Size = int64(buf.Len()) obji := fs.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil) obj, err := remote.Put(in, obji) if err != nil { // Retry if err returned a retry error if fs.IsRetryError(err) && tries < maxTries { t.Logf("Put error: %v - low level retry %d/%d", err, tries, maxTries) time.Sleep(2 * time.Second) tries++ goto again } require.NoError(t, err, "Put error") } file.Hashes = hash.Sums() file.Check(t, obj, remote.Precision()) // Re-read the object and check again obj = findObject(t, file.Path) file.Check(t, obj, remote.Precision()) }
func testPut(t *testing.T, file *fstest.Item) { buf := bytes.NewBufferString(fstest.RandomString(100)) hash := fs.NewMultiHasher() in := io.TeeReader(buf, hash) file.Size = int64(buf.Len()) obj, err := remote.Put(in, file.Path, file.ModTime, file.Size) if err != nil { t.Fatal("Put error", err) } file.Hashes = hash.Sums() file.Check(t, obj, remote.Precision()) // Re-read the object and check again obj = findObject(t, file.Path) file.Check(t, obj, remote.Precision()) }