Skip to content

Commit f3f03ea

Browse files
gitmknanonymous
andauthored
fix: support init (#1612)
Co-authored-by: anonymous <anonymous@mail.org>
1 parent 9497804 commit f3f03ea

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

tencentcloud/basic_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,8 @@ const (
904904

905905
// CI
906906
const (
907-
defaultCiBucket = "terraform-ci-1308919341"
907+
defaultCiBucket = "terraform-ci-1308919341"
908+
defaultStyleName = "terraform_test"
908909
)
909910

910911
// End of CI

tencentcloud/resource_tc_ci_bucket_pic_style_test.go

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
1550
func TestAccTencentCloudCiBucketPicStyleResource_basic(t *testing.T) {
1651
t.Parallel()
@@ -103,15 +138,17 @@ func testAccCheckCiBucketPicStyleExists(re string) resource.TestCheckFunc {
103138
const testAccCiBucketPicStyleVar = `
104139
variable "bucket" {
105140
default = "` + defaultCiBucket + `"
106-
}
107-
141+
}
142+
variable "style_name" {
143+
default = "` + defaultStyleName + `"
144+
}
108145
`
109146

110147
const testAccCiBucketPicStyle = testAccCiBucketPicStyleVar + `
111148
112149
resource "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

Comments
 (0)