Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions tencentcloud/data_source_tc_cos_buckets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ func TestAccTencentCloudCosBucketDataSource_tags(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCosBucketDataSource_tags(appid),
Config: testAccCosBucketDataSource_tags(),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckCosBucketExists("tencentcloud_cos_bucket.bucket_basic"),
resource.TestMatchResourceAttr("data.tencentcloud_cos_buckets.bucket_list", "bucket_list.#", regexp.MustCompile(`^[1-9]\d*$`)),
resource.TestCheckResourceAttr("data.tencentcloud_cos_buckets.bucket_list", "bucket_list.0.tags.test", "test"),
resource.TestCheckResourceAttr("data.tencentcloud_cos_buckets.bucket_list", "bucket_list.0.tags.fixed_resource", "do_not_remove"),
),
},
},
Expand Down Expand Up @@ -105,20 +104,13 @@ data "tencentcloud_cos_buckets" "bucket_list" {
`, acctest.RandInt(), appid)
}

func testAccCosBucketDataSource_tags(appid string) string {
func testAccCosBucketDataSource_tags() string {
return fmt.Sprintf(`
resource "tencentcloud_cos_bucket" "bucket_basic" {
bucket = "tf-tags-%d-%s"

tags = {
"test" = "test"
}
}

%s
data "tencentcloud_cos_buckets" "bucket_list" {
tags = tencentcloud_cos_bucket.bucket_basic.tags
tags = var.fixed_tags
}
`, acctest.RandInt(), appid)
`, fixedTagVariable)
}

func testAccCosBucketDataSource_full(appid string) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

func TestAccTencentCloudCosBucketDomainCertificate_basic(t *testing.T) {
t.Parallel()
id := new(string)

resource.Test(t, resource.TestCase{
Expand Down
14 changes: 8 additions & 6 deletions tencentcloud/service_tencentcloud_cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,15 @@ func (me *CosService) PutBucket(ctx context.Context, bucket, acl string) (errRet
}
}()
ratelimit.Check("CreateBucket")
response, err := me.client.UseCosClient().CreateBucket(&request)
client := me.client.UseCosClient()
response, err := client.CreateBucket(&request)
if err != nil {
errRet = fmt.Errorf("cos put bucket error: %s, bucket: %s", err.Error(), bucket)
return
}

log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
logId, "put bucket", request.String(), response.String())
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s], endpoint %s\n",
logId, "put bucket", request.String(), response.String(), client.Endpoint)

return nil
}
Expand All @@ -154,7 +155,8 @@ func (me *CosService) TencentCosPutBucket(ctx context.Context, bucket string, op
}()

ratelimit.Check("TencentcloudCosPutBucket")
response, err := me.client.UseTencentCosClient(bucket).Bucket.Put(ctx, opt)
client := me.client.UseTencentCosClient(bucket)
response, err := client.Bucket.Put(ctx, opt)

if err != nil {
errRet = fmt.Errorf("cos put bucket error: %s, bucket: %s", err.Error(), bucket)
Expand All @@ -163,8 +165,8 @@ func (me *CosService) TencentCosPutBucket(ctx context.Context, bucket string, op

resp, _ := json.Marshal(response)

log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
logId, "put bucket", req, resp)
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s], baseUrl %s\n",
logId, "put bucket", req, resp, client.BaseURL.BucketURL)

return nil
}
Expand Down