Skip to content

Commit 5418c81

Browse files
authored
fix/cynosdb (#2028)
1 parent 05634f0 commit 5418c81

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
package tencentcloud
22

33
import (
4+
"fmt"
45
"testing"
6+
"time"
57

68
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
79
)
810

911
// go test -i; go test -test.run TestAccTencentCloudCynosdbBinlogDownloadUrlDataSource_basic -v
1012
func TestAccTencentCloudCynosdbBinlogDownloadUrlDataSource_basic(t *testing.T) {
1113
t.Parallel()
14+
loc, _ := time.LoadLocation("Asia/Chongqing")
15+
startTime := time.Now().AddDate(0, 0, -7).In(loc).Format("2006-01-02 15:04:05")
16+
endTime := time.Now().In(loc).Format("2006-01-02 15:04:05")
1217
resource.Test(t, resource.TestCase{
1318
PreCheck: func() {
1419
testAccPreCheck(t)
1520
},
1621
Providers: testAccProviders,
1722
Steps: []resource.TestStep{
1823
{
19-
Config: testAccCynosdbBinlogDownloadUrlDataSource,
24+
Config: fmt.Sprintf(testAccCynosdbBinlogDownloadUrlDataSource, startTime, endTime),
2025
Check: resource.ComposeTestCheckFunc(
2126
testAccCheckTencentCloudDataSourceID("data.tencentcloud_cynosdb_binlog_download_url.binlog_download_url"),
2227
),
@@ -25,9 +30,15 @@ func TestAccTencentCloudCynosdbBinlogDownloadUrlDataSource_basic(t *testing.T) {
2530
})
2631
}
2732

28-
const testAccCynosdbBinlogDownloadUrlDataSource = `
33+
const testAccCynosdbBinlogDownloadUrlDataSource = CommonCynosdb + `
34+
data "tencentcloud_cynosdb_describe_instance_slow_queries" "describe_instance_slow_queries" {
35+
cluster_id = var.cynosdb_cluster_id
36+
start_time = "%s"
37+
end_time = "%s"
38+
}
39+
2940
data "tencentcloud_cynosdb_binlog_download_url" "binlog_download_url" {
30-
cluster_id = "cynosdbmysql-bws8h88b"
31-
binlog_id = 6202249
41+
cluster_id = var.cynosdb_cluster_id
42+
binlog_id = data.tencentcloud_cynosdb_describe_instance_slow_queries.describe_instance_slow_queries.binlogs.0.binlog_id
3243
}
3344
`

0 commit comments

Comments
 (0)