88 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
99)
1010
11+ // go test -i; go test -test.run TestAccTencentCloudClsAlarmResource_basic -v
1112func TestAccTencentCloudClsAlarmResource_basic (t * testing.T ) {
1213 t .Parallel ()
1314 resource .Test (t , resource.TestCase {
@@ -18,12 +19,18 @@ func TestAccTencentCloudClsAlarmResource_basic(t *testing.T) {
1819 Steps : []resource.TestStep {
1920 {
2021 Config : testAccClsAlarm ,
21- Check : resource .ComposeTestCheckFunc (resource .TestCheckResourceAttrSet ("tencentcloud_cls_alarm.alarm" , "id" )),
22+ Check : resource .ComposeTestCheckFunc (
23+ resource .TestCheckResourceAttrSet ("tencentcloud_cls_alarm.alarm" , "id" ),
24+ resource .TestCheckResourceAttr ("tencentcloud_cls_alarm.alarm" , "name" , "tf-example" ),
25+ resource .TestCheckResourceAttr ("tencentcloud_cls_alarm.alarm" , "condition" , "test" ),
26+ ),
2227 },
2328 {
2429 Config : testAccClsAlarmUpdate ,
2530 Check : resource .ComposeTestCheckFunc (
26- resource .TestCheckResourceAttr ("tencentcloud_cls_alarm.alarm" , "name" , "terraform-alarm-for-test" ),
31+ resource .TestCheckResourceAttrSet ("tencentcloud_cls_alarm.alarm" , "id" ),
32+ resource .TestCheckResourceAttr ("tencentcloud_cls_alarm.alarm" , "name" , "tf-example-update" ),
33+ resource .TestCheckResourceAttr ("tencentcloud_cls_alarm.alarm" , "condition" , "test update" ),
2734 ),
2835 },
2936 {
@@ -36,28 +43,28 @@ func TestAccTencentCloudClsAlarmResource_basic(t *testing.T) {
3643}
3744
3845const testAccClsAlarm = `
39-
4046resource "tencentcloud_cls_alarm" "alarm" {
41- name = "terraform-alarm-test "
47+ name = "tf-example "
4248 alarm_notice_ids = [
43- "notice-0850756b-245d-4bc7-bb27-2a58fffc780b ",
49+ "notice-d365c616-1ae2-4a77-863a-9777453ab9d5 ",
4450 ]
4551 alarm_period = 15
4652 condition = "test"
53+ alarm_level = 0
4754 message_template = "{{.Label}}"
4855 status = true
49- tags = {
56+ tags = {
5057 "createdBy" = "terraform"
5158 }
5259 trigger_count = 1
5360
5461 alarm_targets {
5562 end_time_offset = 0
56- logset_id = "33aaf0ae-6163-411b-a415-9f27450f68db "
63+ logset_id = "dac3e1a9-d22c-403b-a129-f94f666a33af "
5764 number = 1
5865 query = "status:>500 | select count(*) as errorCounts"
5966 start_time_offset = -15
60- topic_id = "88735a07-bea4-4985-8763-e9deb6da4fad "
67+ topic_id = "775c0bc2-2246-43a0-8eb2-f5bc248be183 "
6168 }
6269
6370 analysis {
@@ -76,32 +83,31 @@ resource "tencentcloud_cls_alarm" "alarm" {
7683 type = "Period"
7784 }
7885}
79-
8086`
8187
8288const testAccClsAlarmUpdate = `
83-
8489resource "tencentcloud_cls_alarm" "alarm" {
85- name = "terraform-alarm-for-test "
90+ name = "tf-example-update "
8691 alarm_notice_ids = [
87- "notice-0850756b-245d-4bc7-bb27-2a58fffc780b ",
92+ "notice-d365c616-1ae2-4a77-863a-9777453ab9d5 ",
8893 ]
8994 alarm_period = 15
90- condition = "test"
95+ condition = "test update"
96+ alarm_level = 1
9197 message_template = "{{.Label}}"
9298 status = true
93- tags = {
99+ tags = {
94100 "createdBy" = "terraform"
95101 }
96102 trigger_count = 1
97103
98104 alarm_targets {
99105 end_time_offset = 0
100- logset_id = "33aaf0ae-6163-411b-a415-9f27450f68db "
106+ logset_id = "dac3e1a9-d22c-403b-a129-f94f666a33af "
101107 number = 1
102108 query = "status:>500 | select count(*) as errorCounts"
103109 start_time_offset = -15
104- topic_id = "88735a07-bea4-4985-8763-e9deb6da4fad "
110+ topic_id = "775c0bc2-2246-43a0-8eb2-f5bc248be183 "
105111 }
106112
107113 analysis {
@@ -120,5 +126,4 @@ resource "tencentcloud_cls_alarm" "alarm" {
120126 type = "Period"
121127 }
122128}
123-
124129`
0 commit comments