mirror of
https://github.com/rclone/rclone
synced 2024-12-25 17:03:45 +01:00
fstests: allow ObjectUpdate test to retry upload
This commit is contained in:
parent
73beae147f
commit
f7665300c0
@ -1516,19 +1516,21 @@ func Run(t *testing.T, opt *Opt) {
|
|||||||
t.Run("ObjectUpdate", func(t *testing.T) {
|
t.Run("ObjectUpdate", func(t *testing.T) {
|
||||||
skipIfNotOk(t)
|
skipIfNotOk(t)
|
||||||
contents := random.String(200)
|
contents := random.String(200)
|
||||||
buf := bytes.NewBufferString(contents)
|
var h *hash.MultiHasher
|
||||||
hash := hash.NewMultiHasher()
|
|
||||||
in := io.TeeReader(buf, hash)
|
|
||||||
|
|
||||||
file1.Size = int64(buf.Len())
|
file1.Size = int64(len(contents))
|
||||||
obj := findObject(ctx, t, f, file1.Path)
|
obj := findObject(ctx, t, f, file1.Path)
|
||||||
remoteBefore := obj.Remote()
|
remoteBefore := obj.Remote()
|
||||||
obji := object.NewStaticObjectInfo(file1.Path+"-should-be-ignored.bin", file1.ModTime, int64(len(contents)), true, nil, obj.Fs())
|
obji := object.NewStaticObjectInfo(file1.Path+"-should-be-ignored.bin", file1.ModTime, int64(len(contents)), true, nil, obj.Fs())
|
||||||
err := obj.Update(ctx, in, obji)
|
retry(t, "Update object", func() error {
|
||||||
require.NoError(t, err)
|
buf := bytes.NewBufferString(contents)
|
||||||
|
h = hash.NewMultiHasher()
|
||||||
|
in := io.TeeReader(buf, h)
|
||||||
|
return obj.Update(ctx, in, obji)
|
||||||
|
})
|
||||||
remoteAfter := obj.Remote()
|
remoteAfter := obj.Remote()
|
||||||
assert.Equal(t, remoteBefore, remoteAfter, "Remote should not change")
|
assert.Equal(t, remoteBefore, remoteAfter, "Remote should not change")
|
||||||
file1.Hashes = hash.Sums()
|
file1.Hashes = h.Sums()
|
||||||
|
|
||||||
// check the object has been updated
|
// check the object has been updated
|
||||||
file1.Check(t, obj, f.Precision())
|
file1.Check(t, obj, f.Precision())
|
||||||
|
Loading…
Reference in New Issue
Block a user