update test
This commit is contained in:
2
cos.go
2
cos.go
@@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// Version current go sdk version
|
// Version current go sdk version
|
||||||
Version = "0.7.19"
|
Version = "0.7.20"
|
||||||
userAgent = "cos-go-sdk-v5/" + Version
|
userAgent = "cos-go-sdk-v5/" + Version
|
||||||
contentTypeXML = "application/xml"
|
contentTypeXML = "application/xml"
|
||||||
defaultServiceBaseURL = "http://service.cos.myqcloud.com"
|
defaultServiceBaseURL = "http://service.cos.myqcloud.com"
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package cos
|
|||||||
// Basic imports
|
// Basic imports
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@@ -14,7 +13,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
//"github.com/google/uuid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"github.com/tencentyun/cos-go-sdk-v5"
|
"github.com/tencentyun/cos-go-sdk-v5"
|
||||||
@@ -116,6 +115,20 @@ func (s *CosTestSuite) TestGetService() {
|
|||||||
assert.Nil(s.T(), err, "GetService Failed")
|
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
|
// Bucket API
|
||||||
func (s *CosTestSuite) TestPutHeadDeleteBucket() {
|
func (s *CosTestSuite) TestPutHeadDeleteBucket() {
|
||||||
// Notic sometimes the bucket host can not analyis, may has i/o timeout problem
|
// 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")
|
assert.Nil(s.T(), err, "remove tmp file failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (s *CosTestSuite) TestBatch() {
|
func (s *CosTestSuite) TestBatch() {
|
||||||
client := cos.NewClient(s.Client.BaseURL, &http.Client{
|
client := cos.NewClient(s.Client.BaseURL, &http.Client{
|
||||||
Transport: &cos.AuthorizationTransport{
|
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.Status, "Ready", "status failed")
|
||||||
assert.Equal(s.T(), res4.StatusUpdateReason, "to test", "StatusUpdateReason failed")
|
assert.Equal(s.T(), res4.StatusUpdateReason, "to test", "StatusUpdateReason failed")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (s *CosTestSuite) TestEncryption() {
|
func (s *CosTestSuite) TestEncryption() {
|
||||||
opt := &cos.BucketPutEncryptionOptions{
|
opt := &cos.BucketPutEncryptionOptions{
|
||||||
@@ -852,6 +867,7 @@ func (s *CosTestSuite) TestEncryption() {
|
|||||||
_, err := s.Client.Bucket.PutEncryption(context.Background(), opt)
|
_, err := s.Client.Bucket.PutEncryption(context.Background(), opt)
|
||||||
assert.Nil(s.T(), err, "PutEncryption Failed")
|
assert.Nil(s.T(), err, "PutEncryption Failed")
|
||||||
|
|
||||||
|
time.Sleep(time.Second * 2)
|
||||||
res, _, err := s.Client.Bucket.GetEncryption(context.Background())
|
res, _, err := s.Client.Bucket.GetEncryption(context.Background())
|
||||||
assert.Nil(s.T(), err, "GetEncryption Failed")
|
assert.Nil(s.T(), err, "GetEncryption Failed")
|
||||||
assert.Equal(s.T(), opt.Rule.SSEAlgorithm, res.Rule.SSEAlgorithm, "GetEncryption Failed")
|
assert.Equal(s.T(), opt.Rule.SSEAlgorithm, res.Rule.SSEAlgorithm, "GetEncryption Failed")
|
||||||
|
|||||||
Reference in New Issue
Block a user