@@ -11,6 +11,41 @@ import (
1111 "github.com/hashicorp/terraform-plugin-sdk/terraform"
1212)
1313
14+ func init () {
15+ // go test -v ./tencentcloud -sweep=ap-guangzhou -sweep-run=tencentcloud_ci_bucket_pic_style
16+ resource .AddTestSweepers ("tencentcloud_ci_bucket_pic_style" , & resource.Sweeper {
17+ Name : "tencentcloud_ci_bucket_pic_style" ,
18+ F : testSweepCiBucketPicStyle ,
19+ })
20+ }
21+
22+ func testSweepCiBucketPicStyle (region string ) error {
23+ logId := getLogId (contextNil )
24+ ctx := context .WithValue (context .TODO (), logIdKey , logId )
25+ cli , _ := sharedClientForRegion (region )
26+ client := cli .(* TencentCloudClient ).apiV3Conn
27+ service := CiService {client }
28+
29+ bucket := defaultCiBucket
30+ styleName := defaultStyleName
31+
32+ for {
33+ bucketPicStyle , err := service .DescribeCiBucketPicStyleById (ctx , bucket , styleName )
34+ if err != nil {
35+ return nil
36+ }
37+
38+ if bucketPicStyle == nil {
39+ return nil
40+ }
41+
42+ err = service .DeleteCiBucketPicStyleById (ctx , bucket , styleName )
43+ if err != nil {
44+ return err
45+ }
46+ }
47+ }
48+
1449// go test -i; go test -test.run TestAccTencentCloudCiBucketPicStyleResource_basic -v
1550func TestAccTencentCloudCiBucketPicStyleResource_basic (t * testing.T ) {
1651 t .Parallel ()
@@ -103,15 +138,17 @@ func testAccCheckCiBucketPicStyleExists(re string) resource.TestCheckFunc {
103138const testAccCiBucketPicStyleVar = `
104139variable "bucket" {
105140 default = "` + defaultCiBucket + `"
106- }
107-
141+ }
142+ variable "style_name" {
143+ default = "` + defaultStyleName + `"
144+ }
108145`
109146
110147const testAccCiBucketPicStyle = testAccCiBucketPicStyleVar + `
111148
112149resource "tencentcloud_ci_bucket_pic_style" "bucket_pic_style" {
113150 bucket = var.bucket
114- style_name = "terraform_test"
151+ style_name = var.style_name
115152 style_body = "imageMogr2/thumbnail/20x/crop/20x20/gravity/center/interlace/0/quality/100"
116153 }
117154
0 commit comments