update test

This commit is contained in:
jojoliang
2021-02-04 20:22:15 +08:00
parent eb667d9ed9
commit 822a07e20f
2 changed files with 19 additions and 3 deletions

View File

@@ -3,7 +3,6 @@ package cos
// Basic imports
import (
"context"
"errors"
"fmt"
"io/ioutil"
"math/rand"
@@ -14,7 +13,7 @@ import (
"testing"
"time"
"github.com/google/uuid"
//"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/tencentyun/cos-go-sdk-v5"
@@ -116,6 +115,20 @@ func (s *CosTestSuite) TestGetService() {
assert.Nil(s.T(), err, "GetService Failed")
}
func (s *CosTestSuite) TestGetRegionService() {
u, _ := url.Parse("http://cos.ap-guangzhou.myqcloud.com")
b := &cos.BaseURL{ServiceURL: u}
client := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: os.Getenv("COS_SECRETID"),
SecretKey: os.Getenv("COS_SECRETKEY"),
},
})
_, _, err := client.Service.Get(context.Background())
assert.Nil(s.T(), err, "GetService Failed")
}
// Bucket API
func (s *CosTestSuite) TestPutHeadDeleteBucket() {
// Notic sometimes the bucket host can not analyis, may has i/o timeout problem
@@ -735,6 +748,7 @@ func (s *CosTestSuite) TestMultiUpload() {
assert.Nil(s.T(), err, "remove tmp file failed")
}
/*
func (s *CosTestSuite) TestBatch() {
client := cos.NewClient(s.Client.BaseURL, &http.Client{
Transport: &cos.AuthorizationTransport{
@@ -841,6 +855,7 @@ func (s *CosTestSuite) TestBatch() {
assert.Equal(s.T(), res4.Status, "Ready", "status failed")
assert.Equal(s.T(), res4.StatusUpdateReason, "to test", "StatusUpdateReason failed")
}
*/
func (s *CosTestSuite) TestEncryption() {
opt := &cos.BucketPutEncryptionOptions{
@@ -852,6 +867,7 @@ func (s *CosTestSuite) TestEncryption() {
_, err := s.Client.Bucket.PutEncryption(context.Background(), opt)
assert.Nil(s.T(), err, "PutEncryption Failed")
time.Sleep(time.Second * 2)
res, _, err := s.Client.Bucket.GetEncryption(context.Background())
assert.Nil(s.T(), err, "GetEncryption Failed")
assert.Equal(s.T(), opt.Rule.SSEAlgorithm, res.Rule.SSEAlgorithm, "GetEncryption Failed")