update bucket inventory/logging/replication/versioning/tagging and test
This commit is contained in:
@@ -22,7 +22,6 @@ type BucketInventoryFilter struct {
|
|||||||
|
|
||||||
// BucketInventoryOptionalFields ...
|
// BucketInventoryOptionalFields ...
|
||||||
type BucketInventoryOptionalFields struct {
|
type BucketInventoryOptionalFields struct {
|
||||||
XMLName xml.Name `xml:"OptionalFields,omitempty"`
|
|
||||||
BucketInventoryFields []string `xml:"Field,omitempty"`
|
BucketInventoryFields []string `xml:"Field,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,12 +32,11 @@ type BucketInventorySchedule struct {
|
|||||||
|
|
||||||
// BucketInventoryEncryption ...
|
// BucketInventoryEncryption ...
|
||||||
type BucketInventoryEncryption struct {
|
type BucketInventoryEncryption struct {
|
||||||
XMLName xml.Name `xml:"Encryption"`
|
SSECOS string `xml:"SSE-COS"`
|
||||||
SSECOS string `xml:"SSE-COS,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketInventoryDestinationContent ...
|
// BucketInventoryDestination ...
|
||||||
type BucketInventoryDestinationContent struct {
|
type BucketInventoryDestination struct {
|
||||||
Bucket string `xml:"Bucket"`
|
Bucket string `xml:"Bucket"`
|
||||||
AccountId string `xml:"AccountId,omitempty"`
|
AccountId string `xml:"AccountId,omitempty"`
|
||||||
Prefix string `xml:"Prefix,omitempty"`
|
Prefix string `xml:"Prefix,omitempty"`
|
||||||
@@ -46,12 +44,6 @@ type BucketInventoryDestinationContent struct {
|
|||||||
Encryption *BucketInventoryEncryption `xml:"Encryption,omitempty"`
|
Encryption *BucketInventoryEncryption `xml:"Encryption,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketInventoryDestination ...
|
|
||||||
type BucketInventoryDestination struct {
|
|
||||||
XMLName xml.Name `xml:"Destination"`
|
|
||||||
BucketDestination *BucketInventoryDestinationContent `xml:"COSBucketDestination"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// BucketPutInventoryOptions ...
|
// BucketPutInventoryOptions ...
|
||||||
type BucketPutInventoryOptions struct {
|
type BucketPutInventoryOptions struct {
|
||||||
XMLName xml.Name `xml:"InventoryConfiguration"`
|
XMLName xml.Name `xml:"InventoryConfiguration"`
|
||||||
@@ -61,7 +53,7 @@ type BucketPutInventoryOptions struct {
|
|||||||
Filter *BucketInventoryFilter `xml:"Filter,omitempty"`
|
Filter *BucketInventoryFilter `xml:"Filter,omitempty"`
|
||||||
OptionalFields *BucketInventoryOptionalFields `xml:"OptionalFields,omitempty"`
|
OptionalFields *BucketInventoryOptionalFields `xml:"OptionalFields,omitempty"`
|
||||||
Schedule *BucketInventorySchedule `xml:"Schedule"`
|
Schedule *BucketInventorySchedule `xml:"Schedule"`
|
||||||
Destination *BucketInventoryDestination `xml:"Destination"`
|
Destination *BucketInventoryDestination `xml:"Destination>COSBucketDestination"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListBucketInventoryConfigResult result of ListBucketInventoryConfiguration
|
// ListBucketInventoryConfigResult result of ListBucketInventoryConfiguration
|
||||||
@@ -74,7 +66,7 @@ type ListBucketInventoryConfigResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PutBucketInventory https://cloud.tencent.com/document/product/436/33707
|
// PutBucketInventory https://cloud.tencent.com/document/product/436/33707
|
||||||
func (s *BucketService) PutBucketInventoryTest(ctx context.Context, id string, opt *BucketPutInventoryOptions) (*Response, error) {
|
func (s *BucketService) PutInventory(ctx context.Context, id string, opt *BucketPutInventoryOptions) (*Response, error) {
|
||||||
u := fmt.Sprintf("/?inventory&id=%s", id)
|
u := fmt.Sprintf("/?inventory&id=%s", id)
|
||||||
sendOpt := sendOptions{
|
sendOpt := sendOptions{
|
||||||
baseURL: s.client.BaseURL.BucketURL,
|
baseURL: s.client.BaseURL.BucketURL,
|
||||||
@@ -88,7 +80,7 @@ func (s *BucketService) PutBucketInventoryTest(ctx context.Context, id string, o
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetBucketInventory https://cloud.tencent.com/document/product/436/33705
|
// GetBucketInventory https://cloud.tencent.com/document/product/436/33705
|
||||||
func (s *BucketService) GetBucketInventoryTest(ctx context.Context, id string) (*BucketGetInventoryResult, *Response, error) {
|
func (s *BucketService) GetInventory(ctx context.Context, id string) (*BucketGetInventoryResult, *Response, error) {
|
||||||
u := fmt.Sprintf("/?inventory&id=%s", id)
|
u := fmt.Sprintf("/?inventory&id=%s", id)
|
||||||
var res BucketGetInventoryResult
|
var res BucketGetInventoryResult
|
||||||
sendOpt := sendOptions{
|
sendOpt := sendOptions{
|
||||||
@@ -102,7 +94,7 @@ func (s *BucketService) GetBucketInventoryTest(ctx context.Context, id string) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteBucketInventory https://cloud.tencent.com/document/product/436/33704
|
// DeleteBucketInventory https://cloud.tencent.com/document/product/436/33704
|
||||||
func (s *BucketService) DeleteBucketInventoryTest(ctx context.Context, id string) (*Response, error) {
|
func (s *BucketService) DeleteInventory(ctx context.Context, id string) (*Response, error) {
|
||||||
u := fmt.Sprintf("/?inventory&id=%s", id)
|
u := fmt.Sprintf("/?inventory&id=%s", id)
|
||||||
sendOpt := sendOptions{
|
sendOpt := sendOptions{
|
||||||
baseURL: s.client.BaseURL.BucketURL,
|
baseURL: s.client.BaseURL.BucketURL,
|
||||||
@@ -114,7 +106,7 @@ func (s *BucketService) DeleteBucketInventoryTest(ctx context.Context, id string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListBucketInventoryConfigurations https://cloud.tencent.com/document/product/436/33706
|
// ListBucketInventoryConfigurations https://cloud.tencent.com/document/product/436/33706
|
||||||
func (s *BucketService) ListBucketInventoryConfigurationsTest(ctx context.Context, token string) (*ListBucketInventoryConfigResult, *Response, error) {
|
func (s *BucketService) ListInventoryConfigurations(ctx context.Context, token string) (*ListBucketInventoryConfigResult, *Response, error) {
|
||||||
var res ListBucketInventoryConfigResult
|
var res ListBucketInventoryConfigResult
|
||||||
var u string
|
var u string
|
||||||
if token == "" {
|
if token == "" {
|
||||||
|
|||||||
292
bucket_inventory_test.go
Normal file
292
bucket_inventory_test.go
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
package cos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/xml"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBucketService_PutInventory(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
opt := &BucketPutInventoryOptions{
|
||||||
|
XMLName: xml.Name{Local: "InventoryConfiguration"},
|
||||||
|
ID: "list1",
|
||||||
|
IsEnabled: "True",
|
||||||
|
IncludedObjectVersions: "All",
|
||||||
|
Filter: &BucketInventoryFilter{"myPrefix"},
|
||||||
|
Schedule: &BucketInventorySchedule{"Daily"},
|
||||||
|
Destination: &BucketInventoryDestination{
|
||||||
|
Bucket: "qcs::cos:ap-guangzhou::examplebucket-1250000000",
|
||||||
|
AccountId: "100000000001",
|
||||||
|
Prefix: "list1",
|
||||||
|
Format: "CSV",
|
||||||
|
Encryption: &BucketInventoryEncryption{},
|
||||||
|
},
|
||||||
|
OptionalFields: &BucketInventoryOptionalFields{
|
||||||
|
BucketInventoryFields: []string{
|
||||||
|
"Size",
|
||||||
|
"LastModifiedDate",
|
||||||
|
"ETag",
|
||||||
|
"StorageClass",
|
||||||
|
"IsMultipartUploaded",
|
||||||
|
"ReplicationStatus",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodPut)
|
||||||
|
vs := values{
|
||||||
|
"inventory": "",
|
||||||
|
"id": "list1",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
body := &BucketPutInventoryOptions{}
|
||||||
|
xml.NewDecoder(r.Body).Decode(body)
|
||||||
|
want := opt
|
||||||
|
if !reflect.DeepEqual(want, body) {
|
||||||
|
t.Fatalf("Bucket.PutInventory request\n body: %+v\n, want %+v\n", body, want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
_, err := client.Bucket.PutInventory(context.Background(), "list1", opt)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.PutInventory failed, error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBucketService_GetInventory(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodGet)
|
||||||
|
vs := values{
|
||||||
|
"inventory": "",
|
||||||
|
"id": "list1",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
fmt.Fprint(w, `<InventoryConfiguration>
|
||||||
|
<Id>list1</Id>
|
||||||
|
<IsEnabled>True</IsEnabled>
|
||||||
|
<Destination>
|
||||||
|
<COSBucketDestination>
|
||||||
|
<Format>CSV</Format>
|
||||||
|
<Bucket>qcs::cos:ap-guangzhou::examplebucket-1250000000</Bucket>
|
||||||
|
<Prefix>list1</Prefix>
|
||||||
|
<AccountId>100000000001</AccountId>
|
||||||
|
</COSBucketDestination>
|
||||||
|
</Destination>
|
||||||
|
<Schedule>
|
||||||
|
<Frequency>Daily</Frequency>
|
||||||
|
</Schedule>
|
||||||
|
<Filter>
|
||||||
|
<Prefix>myPrefix</Prefix>
|
||||||
|
</Filter>
|
||||||
|
<IncludedObjectVersions>All</IncludedObjectVersions>
|
||||||
|
<OptionalFields>
|
||||||
|
<Field>Size</Field>
|
||||||
|
<Field>LastModifiedDate</Field>
|
||||||
|
<Field>ETag</Field>
|
||||||
|
<Field>StorageClass</Field>
|
||||||
|
<Field>IsMultipartUploaded</Field>
|
||||||
|
<Field>ReplicationStatus</Field>
|
||||||
|
</OptionalFields>
|
||||||
|
</InventoryConfiguration>`)
|
||||||
|
})
|
||||||
|
res, _, err := client.Bucket.GetInventory(context.Background(), "list1")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.GetInventory failed, error: %v", err)
|
||||||
|
}
|
||||||
|
want := &BucketGetInventoryResult{
|
||||||
|
XMLName: xml.Name{Local: "InventoryConfiguration"},
|
||||||
|
ID: "list1",
|
||||||
|
IsEnabled: "True",
|
||||||
|
IncludedObjectVersions: "All",
|
||||||
|
Filter: &BucketInventoryFilter{"myPrefix"},
|
||||||
|
Schedule: &BucketInventorySchedule{"Daily"},
|
||||||
|
Destination: &BucketInventoryDestination{
|
||||||
|
Bucket: "qcs::cos:ap-guangzhou::examplebucket-1250000000",
|
||||||
|
AccountId: "100000000001",
|
||||||
|
Prefix: "list1",
|
||||||
|
Format: "CSV",
|
||||||
|
},
|
||||||
|
OptionalFields: &BucketInventoryOptionalFields{
|
||||||
|
BucketInventoryFields: []string{
|
||||||
|
"Size",
|
||||||
|
"LastModifiedDate",
|
||||||
|
"ETag",
|
||||||
|
"StorageClass",
|
||||||
|
"IsMultipartUploaded",
|
||||||
|
"ReplicationStatus",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(res, want) {
|
||||||
|
t.Errorf("Bucket.GetInventory returned\n%+v, want\n%+v", res, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBucketService_ListInventory(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodGet)
|
||||||
|
vs := values{
|
||||||
|
"inventory": "",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
fmt.Fprint(w, `<ListInventoryConfigurationResult>
|
||||||
|
<InventoryConfiguration>
|
||||||
|
<Id>list1</Id>
|
||||||
|
<IsEnabled>True</IsEnabled>
|
||||||
|
<Destination>
|
||||||
|
<COSBucketDestination>
|
||||||
|
<Format>CSV</Format>
|
||||||
|
<AccountId>1250000000</AccountId>
|
||||||
|
<Bucket>qcs::cos:ap-beijing::examplebucket-1250000000</Bucket>
|
||||||
|
<Prefix>list1</Prefix>
|
||||||
|
<Encryption>
|
||||||
|
<SSE-COS/>
|
||||||
|
</Encryption>
|
||||||
|
</COSBucketDestination>
|
||||||
|
</Destination>
|
||||||
|
<Schedule>
|
||||||
|
<Frequency>Daily</Frequency>
|
||||||
|
</Schedule>
|
||||||
|
<Filter>
|
||||||
|
<Prefix>myPrefix</Prefix>
|
||||||
|
</Filter>
|
||||||
|
<IncludedObjectVersions>All</IncludedObjectVersions>
|
||||||
|
<OptionalFields>
|
||||||
|
<Field>Size</Field>
|
||||||
|
<Field>LastModifiedDate</Field>
|
||||||
|
<Field>ETag</Field>
|
||||||
|
<Field>StorageClass</Field>
|
||||||
|
<Field>IsMultipartUpload</Field>
|
||||||
|
<Field>ReplicationStatus</Field>
|
||||||
|
</OptionalFields>
|
||||||
|
</InventoryConfiguration>
|
||||||
|
<InventoryConfiguration>
|
||||||
|
<Id>list2</Id>
|
||||||
|
<IsEnabled>True</IsEnabled>
|
||||||
|
<Destination>
|
||||||
|
<COSBucketDestination>
|
||||||
|
<Format>CSV</Format>
|
||||||
|
<AccountId>1250000000</AccountId>
|
||||||
|
<Bucket>qcs::cos:ap-beijing::examplebucket-1250000000</Bucket>
|
||||||
|
<Prefix>list2</Prefix>
|
||||||
|
</COSBucketDestination>
|
||||||
|
</Destination>
|
||||||
|
<Schedule>
|
||||||
|
<Frequency>Weekly</Frequency>
|
||||||
|
</Schedule>
|
||||||
|
<Filter>
|
||||||
|
<Prefix>myPrefix2</Prefix>
|
||||||
|
</Filter>
|
||||||
|
<IncludedObjectVersions>All</IncludedObjectVersions>
|
||||||
|
<OptionalFields>
|
||||||
|
<Field>Size</Field>
|
||||||
|
<Field>LastModifiedDate</Field>
|
||||||
|
<Field>ETag</Field>
|
||||||
|
<Field>StorageClass</Field>
|
||||||
|
</OptionalFields>
|
||||||
|
</InventoryConfiguration>
|
||||||
|
<IsTruncated>false</IsTruncated>
|
||||||
|
<ContinuationToken>...</ContinuationToken>
|
||||||
|
<IsTruncated>true</IsTruncated>
|
||||||
|
<NextContinuationToken>1ueSDFASDF1Tr/XDAFdadEADadf2J/wm36Hy4vbOwM=</NextContinuationToken>
|
||||||
|
</ListInventoryConfigurationResult>`)
|
||||||
|
})
|
||||||
|
|
||||||
|
res, _, err := client.Bucket.ListInventoryConfigurations(context.Background(), "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.ListInventory failed, error: %v", err)
|
||||||
|
}
|
||||||
|
want := &ListBucketInventoryConfigResult{
|
||||||
|
XMLName: xml.Name{Local: "ListInventoryConfigurationResult"},
|
||||||
|
IsTruncated: true,
|
||||||
|
ContinuationToken: "...",
|
||||||
|
NextContinuationToken: "1ueSDFASDF1Tr/XDAFdadEADadf2J/wm36Hy4vbOwM=",
|
||||||
|
InventoryConfigurations: []BucketListInventoryConfiguartion{
|
||||||
|
BucketListInventoryConfiguartion{
|
||||||
|
XMLName: xml.Name{Local: "InventoryConfiguration"},
|
||||||
|
ID: "list1",
|
||||||
|
IsEnabled: "True",
|
||||||
|
IncludedObjectVersions: "All",
|
||||||
|
Filter: &BucketInventoryFilter{"myPrefix"},
|
||||||
|
Schedule: &BucketInventorySchedule{"Daily"},
|
||||||
|
Destination: &BucketInventoryDestination{
|
||||||
|
Bucket: "qcs::cos:ap-beijing::examplebucket-1250000000",
|
||||||
|
AccountId: "1250000000",
|
||||||
|
Prefix: "list1",
|
||||||
|
Format: "CSV",
|
||||||
|
Encryption: &BucketInventoryEncryption{},
|
||||||
|
},
|
||||||
|
OptionalFields: &BucketInventoryOptionalFields{
|
||||||
|
BucketInventoryFields: []string{
|
||||||
|
"Size",
|
||||||
|
"LastModifiedDate",
|
||||||
|
"ETag",
|
||||||
|
"StorageClass",
|
||||||
|
"IsMultipartUpload",
|
||||||
|
"ReplicationStatus",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
BucketListInventoryConfiguartion{
|
||||||
|
XMLName: xml.Name{Local: "InventoryConfiguration"},
|
||||||
|
ID: "list2",
|
||||||
|
IsEnabled: "True",
|
||||||
|
IncludedObjectVersions: "All",
|
||||||
|
Filter: &BucketInventoryFilter{"myPrefix2"},
|
||||||
|
Schedule: &BucketInventorySchedule{"Weekly"},
|
||||||
|
Destination: &BucketInventoryDestination{
|
||||||
|
Bucket: "qcs::cos:ap-beijing::examplebucket-1250000000",
|
||||||
|
AccountId: "1250000000",
|
||||||
|
Prefix: "list2",
|
||||||
|
Format: "CSV",
|
||||||
|
},
|
||||||
|
OptionalFields: &BucketInventoryOptionalFields{
|
||||||
|
BucketInventoryFields: []string{
|
||||||
|
"Size",
|
||||||
|
"LastModifiedDate",
|
||||||
|
"ETag",
|
||||||
|
"StorageClass",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(res, want) {
|
||||||
|
t.Fatalf("Bucket.ListInventory failed, \nwant: %+v\nres: %+v", want, res)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBucketService_DeleteInventory(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodDelete)
|
||||||
|
vs := values{
|
||||||
|
"inventory": "",
|
||||||
|
"id": "list1",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
})
|
||||||
|
|
||||||
|
_, err := client.Bucket.DeleteInventory(context.Background(), "list1")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.DeleteInventory returned error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,17 +17,14 @@ type BucketLoggingEnabled struct {
|
|||||||
// BucketPutLoggingOptions is the options of PutBucketLogging
|
// BucketPutLoggingOptions is the options of PutBucketLogging
|
||||||
type BucketPutLoggingOptions struct {
|
type BucketPutLoggingOptions struct {
|
||||||
XMLName xml.Name `xml:"BucketLoggingStatus"`
|
XMLName xml.Name `xml:"BucketLoggingStatus"`
|
||||||
LoggingEnabled *BucketLoggingEnabled `xml:"LoggingEnabled"`
|
LoggingEnabled *BucketLoggingEnabled `xml:"LoggingEnabled,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketGetLoggingResult is the result of GetBucketLogging
|
// BucketGetLoggingResult is the result of GetBucketLogging
|
||||||
type BucketGetLoggingResult struct {
|
type BucketGetLoggingResult BucketPutLoggingOptions
|
||||||
XMLName xml.Name `xml:"BucketLoggingStatus"`
|
|
||||||
LoggingEnabled *BucketLoggingEnabled `xml:"LoggingEnabled"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutBucketLogging https://cloud.tencent.com/document/product/436/17054
|
// PutBucketLogging https://cloud.tencent.com/document/product/436/17054
|
||||||
func (s *BucketService) PutBucketLoggingTest(ctx context.Context, opt *BucketPutLoggingOptions) (*Response, error) {
|
func (s *BucketService) PutLogging(ctx context.Context, opt *BucketPutLoggingOptions) (*Response, error) {
|
||||||
sendOpt := sendOptions{
|
sendOpt := sendOptions{
|
||||||
baseURL: s.client.BaseURL.BucketURL,
|
baseURL: s.client.BaseURL.BucketURL,
|
||||||
uri: "/?logging",
|
uri: "/?logging",
|
||||||
@@ -39,7 +36,7 @@ func (s *BucketService) PutBucketLoggingTest(ctx context.Context, opt *BucketPut
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetBucketLogging https://cloud.tencent.com/document/product/436/17053
|
// GetBucketLogging https://cloud.tencent.com/document/product/436/17053
|
||||||
func (s *BucketService) GetBucketLoggingTest(ctx context.Context) (*BucketGetLoggingResult, *Response, error) {
|
func (s *BucketService) GetLogging(ctx context.Context) (*BucketGetLoggingResult, *Response, error) {
|
||||||
var res BucketGetLoggingResult
|
var res BucketGetLoggingResult
|
||||||
sendOpt := sendOptions{
|
sendOpt := sendOptions{
|
||||||
baseURL: s.client.BaseURL.BucketURL,
|
baseURL: s.client.BaseURL.BucketURL,
|
||||||
|
|||||||
75
bucket_logging_test.go
Normal file
75
bucket_logging_test.go
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
package cos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/xml"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBucketService_PutLogging(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
opt := &BucketPutLoggingOptions{
|
||||||
|
LoggingEnabled: &BucketLoggingEnabled{
|
||||||
|
TargetBucket: "logs",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodPut)
|
||||||
|
vs := values{
|
||||||
|
"logging": "",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
body := &BucketPutLoggingOptions{}
|
||||||
|
xml.NewDecoder(r.Body).Decode(body)
|
||||||
|
want := opt
|
||||||
|
want.XMLName = xml.Name{Local: "BucketLoggingStatus"}
|
||||||
|
if !reflect.DeepEqual(want, body) {
|
||||||
|
t.Fatalf("Bucket.PutLogging request\n body: %+v\n, want %+v\n", body, want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
_, err := client.Bucket.PutLogging(context.Background(), opt)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.PutLogging failed, error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBucketService_GetLogging(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodGet)
|
||||||
|
vs := values{
|
||||||
|
"logging": "",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
fmt.Fprint(w, `<BucketLoggingStatus>
|
||||||
|
<LoggingEnabled>
|
||||||
|
<TargetBucket>logs</TargetBucket>
|
||||||
|
<TargetPrefix>mylogs</TargetPrefix>
|
||||||
|
</LoggingEnabled>
|
||||||
|
</BucketLoggingStatus>`)
|
||||||
|
})
|
||||||
|
res, _, err := client.Bucket.GetLogging(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.GetLogging failed, error: %v", err)
|
||||||
|
}
|
||||||
|
want := &BucketGetLoggingResult{
|
||||||
|
XMLName: xml.Name{Local: "BucketLoggingStatus"},
|
||||||
|
LoggingEnabled: &BucketLoggingEnabled{
|
||||||
|
TargetBucket: "logs",
|
||||||
|
TargetPrefix: "mylogs",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(res, want) {
|
||||||
|
t.Errorf("Bucket.GetLogging returned\n%+v, want\n%+v", res, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,11 +28,7 @@ type PutBucketReplicationOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetBucketReplicationResult is the result of GetBucketReplication
|
// GetBucketReplicationResult is the result of GetBucketReplication
|
||||||
type GetBucketReplicationResult struct {
|
type GetBucketReplicationResult PutBucketReplicationOptions
|
||||||
XMLName xml.Name `xml:"ReplicationConfiguration"`
|
|
||||||
Role string `xml:"Role"`
|
|
||||||
Rule []BucketReplicationRule `xml:"Rule"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutBucketReplication https://cloud.tencent.com/document/product/436/19223
|
// PutBucketReplication https://cloud.tencent.com/document/product/436/19223
|
||||||
func (s *BucketService) PutBucketReplication(ctx context.Context, opt *PutBucketReplicationOptions) (*Response, error) {
|
func (s *BucketService) PutBucketReplication(ctx context.Context, opt *PutBucketReplicationOptions) (*Response, error) {
|
||||||
|
|||||||
115
bucket_replication_test.go
Normal file
115
bucket_replication_test.go
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
package cos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/xml"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBucketService_PutReplication(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
opt := &PutBucketReplicationOptions{
|
||||||
|
Role: "qcs::cam::uin/100000000001:uin/100000000001",
|
||||||
|
Rule: []BucketReplicationRule{
|
||||||
|
{
|
||||||
|
Status: "Disabled",
|
||||||
|
Prefix: "prefix",
|
||||||
|
Destination: &ReplicationDestination{
|
||||||
|
Bucket: "qcs::cos:ap-beijing-1::examplebucket-1250000000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodPut)
|
||||||
|
vs := values{
|
||||||
|
"replication": "",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
body := &PutBucketReplicationOptions{}
|
||||||
|
xml.NewDecoder(r.Body).Decode(body)
|
||||||
|
want := opt
|
||||||
|
want.XMLName = xml.Name{Local: "ReplicationConfiguration"}
|
||||||
|
if !reflect.DeepEqual(want, body) {
|
||||||
|
t.Fatalf("Bucket.PutReplication request\n body: %+v\n, want %+v\n", body, want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
_, err := client.Bucket.PutBucketReplication(context.Background(), opt)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.PutLogging failed, error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBucketService_GetReplication(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodGet)
|
||||||
|
vs := values{
|
||||||
|
"replication": "",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
fmt.Fprint(w, `<ReplicationConfiguration>
|
||||||
|
<Role>qcs::cam::uin/100000000001:uin/100000000001</Role>
|
||||||
|
<Rule>
|
||||||
|
<Status>Disabled</Status>
|
||||||
|
<ID></ID>
|
||||||
|
<Prefix>prefix</Prefix>
|
||||||
|
<Destination>
|
||||||
|
<Bucket>qcs::cos:ap-beijing-1::examplebucket-1250000000</Bucket>
|
||||||
|
</Destination>
|
||||||
|
</Rule>
|
||||||
|
</ReplicationConfiguration>`)
|
||||||
|
|
||||||
|
})
|
||||||
|
res, _, err := client.Bucket.GetBucketReplication(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.GetReplication failed, error: %v", err)
|
||||||
|
}
|
||||||
|
want := &GetBucketReplicationResult{
|
||||||
|
XMLName: xml.Name{Local: "ReplicationConfiguration"},
|
||||||
|
Role: "qcs::cam::uin/100000000001:uin/100000000001",
|
||||||
|
Rule: []BucketReplicationRule{
|
||||||
|
{
|
||||||
|
Status: "Disabled",
|
||||||
|
Prefix: "prefix",
|
||||||
|
Destination: &ReplicationDestination{
|
||||||
|
Bucket: "qcs::cos:ap-beijing-1::examplebucket-1250000000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(res, want) {
|
||||||
|
t.Errorf("Bucket.GetBucketReplication\nres %+v\nwant %+v", res.Rule[0].Destination, want.Rule[0].Destination)
|
||||||
|
t.Errorf("Bucket.GetBucketReplication\nres %+v\nwant %+v", res, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBucketService_DeleteReplication(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodDelete)
|
||||||
|
vs := values{
|
||||||
|
"replication": "",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
})
|
||||||
|
|
||||||
|
_, err := client.Bucket.DeleteBucketReplication(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.DeleteBucketReplication returned error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,10 +13,7 @@ type BucketPutVersionOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BucketGetVersionResult is the result of GetBucketVersioning
|
// BucketGetVersionResult is the result of GetBucketVersioning
|
||||||
type BucketGetVersionResult struct {
|
type BucketGetVersionResult BucketPutVersionOptions
|
||||||
XMLName xml.Name `xml:"VersioningConfiguration"`
|
|
||||||
Status string `xml:"Status"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutVersion https://cloud.tencent.com/document/product/436/19889
|
// PutVersion https://cloud.tencent.com/document/product/436/19889
|
||||||
// Status has Suspended\Enabled
|
// Status has Suspended\Enabled
|
||||||
|
|||||||
67
bucket_version_test.go
Normal file
67
bucket_version_test.go
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package cos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/xml"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBucketService_PutVersioning(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
opt := &BucketPutVersionOptions{
|
||||||
|
Status: "Suspended",
|
||||||
|
}
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodPut)
|
||||||
|
vs := values{
|
||||||
|
"versioning": "",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
body := &BucketPutVersionOptions{}
|
||||||
|
xml.NewDecoder(r.Body).Decode(body)
|
||||||
|
want := opt
|
||||||
|
want.XMLName = xml.Name{Local: "VersioningConfiguration"}
|
||||||
|
if !reflect.DeepEqual(want, body) {
|
||||||
|
t.Fatalf("Bucket.PutVersioning request\nbody: %+v\nwant %+v\n", body, want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
_, err := client.Bucket.PutVersioning(context.Background(), opt)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.PutVersioning failed, error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBucketService_GetVersioning(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, http.MethodGet)
|
||||||
|
vs := values{
|
||||||
|
"versioning": "",
|
||||||
|
}
|
||||||
|
testFormValues(t, r, vs)
|
||||||
|
|
||||||
|
fmt.Fprint(w, `<VersioningConfiguration>
|
||||||
|
<Status>Suspended</Status>
|
||||||
|
</VersioningConfiguration>`)
|
||||||
|
})
|
||||||
|
res, _, err := client.Bucket.GetVersioning(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Bucket.GetVersioning failed, error: %v", err)
|
||||||
|
}
|
||||||
|
want := &BucketGetVersionResult{
|
||||||
|
XMLName: xml.Name{Local: "VersioningConfiguration"},
|
||||||
|
Status: "Suspended",
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(res, want) {
|
||||||
|
t.Errorf("Bucket.GetVersioning returned\n%+v, want\n%+v", res, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,6 +44,16 @@ type CosTestSuite struct {
|
|||||||
SepFileName string
|
SepFileName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace
|
||||||
|
const (
|
||||||
|
//uin
|
||||||
|
kUin = "100010805041"
|
||||||
|
//Replication Target Region,
|
||||||
|
kRepRegion = "ap-chengdu"
|
||||||
|
//Replication Target Bucket, Version management needs to be turned on beforehand
|
||||||
|
kRepBucket = "cosgosdkreptest"
|
||||||
|
)
|
||||||
|
|
||||||
func (s *CosTestSuite) SetupSuite() {
|
func (s *CosTestSuite) SetupSuite() {
|
||||||
fmt.Println("Set up test")
|
fmt.Println("Set up test")
|
||||||
// init
|
// init
|
||||||
@@ -52,7 +62,7 @@ func (s *CosTestSuite) SetupSuite() {
|
|||||||
|
|
||||||
// CI client for test interface
|
// CI client for test interface
|
||||||
// URL like this http://test-1253846586.cos.ap-guangzhou.myqcloud.com
|
// URL like this http://test-1253846586.cos.ap-guangzhou.myqcloud.com
|
||||||
u := "http://cosgosdktest-1251668577.cos.ap-guangzhou.myqcloud.com"
|
u := "https://cosgosdktest-1259654469.cos.ap-guangzhou.myqcloud.com"
|
||||||
|
|
||||||
// Get the region
|
// Get the region
|
||||||
iu, _ := url.Parse(u)
|
iu, _ := url.Parse(u)
|
||||||
@@ -199,7 +209,7 @@ func (s *CosTestSuite) TestVersionAndReplication() {
|
|||||||
|
|
||||||
repOpt := &cos.PutBucketReplicationOptions{
|
repOpt := &cos.PutBucketReplicationOptions{
|
||||||
// qcs::cam::uin/[UIN]:uin/[Subaccount]
|
// qcs::cam::uin/[UIN]:uin/[Subaccount]
|
||||||
Role: "qcs::cam::uin/2779643970:uin/2779643970",
|
Role: "qcs::cam::uin/" + kUin + ":uin/" + kUin,
|
||||||
Rule: []cos.BucketReplicationRule{
|
Rule: []cos.BucketReplicationRule{
|
||||||
{
|
{
|
||||||
ID: "1",
|
ID: "1",
|
||||||
@@ -207,7 +217,7 @@ func (s *CosTestSuite) TestVersionAndReplication() {
|
|||||||
Status: "Enabled",
|
Status: "Enabled",
|
||||||
Destination: &cos.ReplicationDestination{
|
Destination: &cos.ReplicationDestination{
|
||||||
// qcs::cos:[Region]::[Bucketname-Appid]
|
// qcs::cos:[Region]::[Bucketname-Appid]
|
||||||
Bucket: "qcs::cos:ap-beijing::alanbj-1251668577",
|
Bucket: "qcs::cos:" + kRepRegion + "::" + kRepBucket + "-" + s.Appid,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -219,7 +229,7 @@ func (s *CosTestSuite) TestVersionAndReplication() {
|
|||||||
assert.Nil(s.T(), err, "GetBucketReplication Failed")
|
assert.Nil(s.T(), err, "GetBucketReplication Failed")
|
||||||
for _, r := range vr.Rule {
|
for _, r := range vr.Rule {
|
||||||
assert.Equal(s.T(), "Enabled", r.Status, "Get Wrong Version status")
|
assert.Equal(s.T(), "Enabled", r.Status, "Get Wrong Version status")
|
||||||
assert.Equal(s.T(), "qcs::cos:ap-beijing::alanbj-1251668577", r.Destination.Bucket, "Get Wrong Version status")
|
assert.Equal(s.T(), "qcs::cos:"+kRepRegion+"::"+kRepBucket+"-"+s.Appid, r.Destination.Bucket, "Get Wrong Version status")
|
||||||
|
|
||||||
}
|
}
|
||||||
_, err = s.Client.Bucket.DeleteBucketReplication(context.Background())
|
_, err = s.Client.Bucket.DeleteBucketReplication(context.Background())
|
||||||
@@ -228,6 +238,7 @@ func (s *CosTestSuite) TestVersionAndReplication() {
|
|||||||
|
|
||||||
func (s *CosTestSuite) TestBucketInventory() {
|
func (s *CosTestSuite) TestBucketInventory() {
|
||||||
id := "test1"
|
id := "test1"
|
||||||
|
dBucket := "qcs::cos:" + s.Region + "::" + s.Bucket + "-" + s.Appid
|
||||||
opt := &cos.BucketPutInventoryOptions{
|
opt := &cos.BucketPutInventoryOptions{
|
||||||
ID: id,
|
ID: id,
|
||||||
// True or False
|
// True or False
|
||||||
@@ -246,38 +257,57 @@ func (s *CosTestSuite) TestBucketInventory() {
|
|||||||
Frequency: "Daily",
|
Frequency: "Daily",
|
||||||
},
|
},
|
||||||
Destination: &cos.BucketInventoryDestination{
|
Destination: &cos.BucketInventoryDestination{
|
||||||
BucketDestination: &cos.BucketInventoryDestinationContent{
|
Bucket: dBucket,
|
||||||
Bucket: "qcs::cos:ap-guangzhou::alangz-1251668577",
|
Format: "CSV",
|
||||||
Format: "CSV",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err := s.Client.Bucket.PutBucketInventoryTest(context.Background(), id, opt)
|
_, err := s.Client.Bucket.PutInventory(context.Background(), id, opt)
|
||||||
assert.Nil(s.T(), err, "PutBucketInventory Failed")
|
assert.Nil(s.T(), err, "PutBucketInventory Failed")
|
||||||
v, _, err := s.Client.Bucket.GetBucketInventoryTest(context.Background(), id)
|
v, _, err := s.Client.Bucket.GetInventory(context.Background(), id)
|
||||||
assert.Nil(s.T(), err, "GetBucketInventory Failed")
|
assert.Nil(s.T(), err, "GetBucketInventory Failed")
|
||||||
assert.Equal(s.T(), "test1", v.ID, "Get Wrong inventory id")
|
assert.Equal(s.T(), "test1", v.ID, "Get Wrong inventory id")
|
||||||
assert.Equal(s.T(), "true", v.IsEnabled, "Get Wrong inventory isenabled")
|
assert.Equal(s.T(), "true", v.IsEnabled, "Get Wrong inventory isenabled")
|
||||||
assert.Equal(s.T(), "qcs::cos:ap-guangzhou::alangz-1251668577", v.Destination.BucketDestination.Bucket, "Get Wrong inventory isenabled")
|
assert.Equal(s.T(), dBucket, v.Destination.Bucket, "Get Wrong inventory isenabled")
|
||||||
|
|
||||||
_, err = s.Client.Bucket.DeleteBucketInventoryTest(context.Background(), id)
|
_, err = s.Client.Bucket.DeleteInventory(context.Background(), id)
|
||||||
assert.Nil(s.T(), err, "DeleteBucketInventory Failed")
|
assert.Nil(s.T(), err, "DeleteBucketInventory Failed")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CosTestSuite) TestBucketLogging() {
|
func (s *CosTestSuite) TestBucketLogging() {
|
||||||
|
tBucket := s.Bucket + "-" + s.Appid
|
||||||
opt := &cos.BucketPutLoggingOptions{
|
opt := &cos.BucketPutLoggingOptions{
|
||||||
LoggingEnabled: &cos.BucketLoggingEnabled{
|
LoggingEnabled: &cos.BucketLoggingEnabled{
|
||||||
// The bucket must same region.
|
TargetBucket: tBucket,
|
||||||
TargetBucket: "alangz-1251668577",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err := s.Client.Bucket.PutBucketLoggingTest(context.Background(), opt)
|
_, err := s.Client.Bucket.PutLogging(context.Background(), opt)
|
||||||
assert.Nil(s.T(), err, "PutBucketLogging Failed")
|
assert.Nil(s.T(), err, "PutLogging Failed")
|
||||||
v, _, err := s.Client.Bucket.GetBucketLoggingTest(context.Background())
|
v, _, err := s.Client.Bucket.GetLogging(context.Background())
|
||||||
assert.Nil(s.T(), err, "GetBucketLogging Failed")
|
assert.Nil(s.T(), err, "GetLogging Failed")
|
||||||
assert.Equal(s.T(), "alangz-1251668577", v.LoggingEnabled.TargetBucket, "Get Wrong Version status")
|
assert.Equal(s.T(), tBucket, v.LoggingEnabled.TargetBucket, "Get Wrong Version status")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *CosTestSuite) TestBucketTagging() {
|
||||||
|
opt := &cos.BucketPutTaggingOptions{
|
||||||
|
TagSet: []cos.BucketTaggingTag{
|
||||||
|
{
|
||||||
|
Key: "testk1",
|
||||||
|
Value: "testv1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "testk2",
|
||||||
|
Value: "testv2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_, err := s.Client.Bucket.PutTagging(context.Background(), opt)
|
||||||
|
assert.Nil(s.T(), err, "Put Tagging Failed")
|
||||||
|
v, _, err := s.Client.Bucket.GetTagging(context.Background())
|
||||||
|
assert.Nil(s.T(), err, "Get Tagging Failed")
|
||||||
|
assert.Equal(s.T(), v.TagSet[0].Key, opt.TagSet[0].Key, "Get Wrong Tag key")
|
||||||
|
assert.Equal(s.T(), v.TagSet[0].Value, opt.TagSet[0].Value, "Get Wrong Tag value")
|
||||||
|
assert.Equal(s.T(), v.TagSet[1].Key, opt.TagSet[1].Key, "Get Wrong Tag key")
|
||||||
|
assert.Equal(s.T(), v.TagSet[1].Value, opt.TagSet[1].Value, "Get Wrong Tag value")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CosTestSuite) TestPutGetDeleteLifeCycle() {
|
func (s *CosTestSuite) TestPutGetDeleteLifeCycle() {
|
||||||
@@ -491,7 +521,7 @@ func (s *CosTestSuite) TestPutObjectRestore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CosTestSuite) TestCopyObject() {
|
func (s *CosTestSuite) TestCopyObject() {
|
||||||
u := "http://gosdkcopytest-" + s.Appid + ".cos.ap-beijing-1.myqcloud.com"
|
u := "http://" + kRepBucket + "-" + s.Appid + ".cos." + kRepRegion + ".myqcloud.com"
|
||||||
iu, _ := url.Parse(u)
|
iu, _ := url.Parse(u)
|
||||||
ib := &cos.BaseURL{BucketURL: iu}
|
ib := &cos.BaseURL{BucketURL: iu}
|
||||||
c := cos.NewClient(ib, &http.Client{
|
c := cos.NewClient(ib, &http.Client{
|
||||||
|
|||||||
Reference in New Issue
Block a user