add append && add retry

This commit is contained in:
jojoliang
2021-08-25 20:05:22 +08:00
parent a505960fe4
commit 6d06f3452d
30 changed files with 436 additions and 156 deletions

View File

@@ -2,6 +2,7 @@ package cos
// Basic imports
import (
"bytes"
"context"
"fmt"
"io/ioutil"
@@ -812,6 +813,21 @@ func (s *CosTestSuite) TestMultiUpload() {
assert.Nil(s.T(), err, "remove tmp file failed")
}
func (s *CosTestSuite) TestAppend() {
name := "append" + time.Now().Format(time.RFC3339)
b1 := make([]byte, 1024*1024*10)
_, err := rand.Read(b1)
pos, _, err := s.Client.Object.Append(context.Background(), name, 0, bytes.NewReader(b1), nil)
assert.Nil(s.T(), err, "append object failed")
assert.Equal(s.T(), len(b1), pos, "append object pos error")
b2 := make([]byte, 12345)
rand.Read(b2)
pos, _, err = s.Client.Object.Append(context.Background(), name, pos, bytes.NewReader(b2), nil)
assert.Nil(s.T(), err, "append object failed")
assert.Equal(s.T(), len(b1)+len(b2), pos, "append object pos error")
}
/*
func (s *CosTestSuite) TestBatch() {
client := cos.NewClient(s.Client.BaseURL, &http.Client{