File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 11package tencentcloud
22
33import (
4+ "context"
45 "testing"
6+ "time"
57
68 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
9+ lighthouse "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lighthouse/v20200324"
710)
811
12+ func init () {
13+ // go test -v ./tencentcloud -sweep=ap-guangzhou -sweep-run=tencentcloud_lighthouse_instance
14+ resource .AddTestSweepers ("tencentcloud_lighthouse_instance" , & resource.Sweeper {
15+ Name : "tencentcloud_lighthouse_instance" ,
16+ F : func (r string ) error {
17+ logId := getLogId (contextNil )
18+ ctx := context .WithValue (context .TODO (), logIdKey , logId )
19+ cli , _ := sharedClientForRegion (r )
20+
21+ request := lighthouse .NewDescribeInstancesRequest ()
22+ response , err := cli .(* TencentCloudClient ).apiV3Conn .UseLighthouseClient ().DescribeInstances (request )
23+ if err != nil {
24+ return err
25+ }
26+ instances := response .Response .InstanceSet
27+ service := LightHouseService {client : cli .(* TencentCloudClient ).apiV3Conn }
28+
29+ for _ , instance := range instances {
30+ name := * instance .InstanceName
31+ created , err := time .Parse ("2006-01-02 15:04:05" , * instance .CreatedTime )
32+ if err != nil {
33+ continue
34+ }
35+ if isResourcePersist (name , & created ) {
36+ continue
37+ }
38+ if innerErr := service .DeleteLighthouseInstanceById (ctx , * instance .InstanceId ); innerErr != nil {
39+ continue
40+ }
41+ }
42+ return nil
43+ },
44+ })
45+ }
46+
947func TestAccTencentCloudLighthouseInstance_basic (t * testing.T ) {
1048 t .Parallel ()
1149
You can’t perform that action at this time.
0 commit comments