1
- package teo
1
+ package teo_test
2
2
3
3
import (
4
4
"testing"
@@ -15,20 +15,176 @@ func TestAccTencentCloudTeoFunctionRuleResource_basic(t *testing.T) {
15
15
tcacctest .AccPreCheck (t )
16
16
},
17
17
Providers : tcacctest .AccProviders ,
18
- Steps : []resource.TestStep {{
19
- Config : testAccTeoFunctionRule ,
20
- Check : resource .ComposeTestCheckFunc (resource .TestCheckResourceAttrSet ("tencentcloud_teo_function_rule.teo_function_rule" , "id" )),
21
- }, {
22
- ResourceName : "tencentcloud_teo_function_rule.teo_function_rule" ,
23
- ImportState : true ,
24
- ImportStateVerify : true ,
25
- }},
18
+ Steps : []resource.TestStep {
19
+ {
20
+ Config : testAccTeoFunctionRule ,
21
+ Check : resource .ComposeTestCheckFunc (
22
+ resource .TestCheckResourceAttrSet ("tencentcloud_teo_function_rule.teo_function_rule" , "id" ),
23
+ resource .TestCheckResourceAttrSet ("tencentcloud_teo_function_rule.teo_function_rule" , "function_id" ),
24
+ resource .TestCheckResourceAttrSet ("tencentcloud_teo_function_rule.teo_function_rule" , "zone_id" ),
25
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "remark" , "aaa" ),
26
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.#" , "2" ),
27
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.#" , "2" ),
28
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.ignore_case" , "false" ),
29
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.operator" , "equal" ),
30
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.target" , "host" ),
31
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.values.#" , "1" ),
32
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.values.0" , "aaa.makn.cn" ),
33
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.ignore_case" , "false" ),
34
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.operator" , "equal" ),
35
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.target" , "extension" ),
36
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.values.#" , "1" ),
37
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.values.0" , ".txt" ),
38
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.#" , "2" ),
39
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.ignore_case" , "false" ),
40
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.operator" , "notequal" ),
41
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.target" , "host" ),
42
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.values.#" , "1" ),
43
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.values.0" , "aaa.makn.cn" ),
44
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.ignore_case" , "false" ),
45
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.operator" , "equal" ),
46
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.target" , "extension" ),
47
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.values.#" , "1" ),
48
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.values.0" , ".png" ),
49
+ ),
50
+ },
51
+ {
52
+ ResourceName : "tencentcloud_teo_function_rule.teo_function_rule" ,
53
+ ImportState : true ,
54
+ ImportStateVerify : true ,
55
+ },
56
+ {
57
+ Config : testAccTeoFunctionRuleUp ,
58
+ Check : resource .ComposeTestCheckFunc (
59
+ resource .TestCheckResourceAttrSet ("tencentcloud_teo_function_rule.teo_function_rule" , "id" ),
60
+ resource .TestCheckResourceAttrSet ("tencentcloud_teo_function_rule.teo_function_rule" , "function_id" ),
61
+ resource .TestCheckResourceAttrSet ("tencentcloud_teo_function_rule.teo_function_rule" , "zone_id" ),
62
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "remark" , "bbb" ),
63
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.#" , "2" ),
64
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.#" , "2" ),
65
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.ignore_case" , "false" ),
66
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.operator" , "notequal" ),
67
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.target" , "host" ),
68
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.values.#" , "1" ),
69
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.0.values.0" , "aaa.makn.cn" ),
70
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.ignore_case" , "false" ),
71
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.operator" , "equal" ),
72
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.target" , "extension" ),
73
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.values.#" , "1" ),
74
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.0.rule_conditions.1.values.0" , ".txt" ),
75
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.#" , "2" ),
76
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.ignore_case" , "false" ),
77
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.operator" , "notequal" ),
78
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.target" , "host" ),
79
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.values.#" , "1" ),
80
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.0.values.0" , "aaa.makn.cn" ),
81
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.ignore_case" , "false" ),
82
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.operator" , "equal" ),
83
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.target" , "extension" ),
84
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.values.#" , "1" ),
85
+ resource .TestCheckResourceAttr ("tencentcloud_teo_function_rule.teo_function_rule" , "function_rule_conditions.1.rule_conditions.1.values.0" , ".png" ),
86
+ ),
87
+ },
88
+ },
26
89
})
27
90
}
28
91
29
92
const testAccTeoFunctionRule = `
30
93
31
94
resource "tencentcloud_teo_function_rule" "teo_function_rule" {
32
- function_rule_conditions = ""
95
+ function_id = "ef-txx7fnua"
96
+ remark = "aaa"
97
+ zone_id = "zone-2qtuhspy7cr6"
98
+
99
+ function_rule_conditions {
100
+ rule_conditions {
101
+ ignore_case = false
102
+ name = null
103
+ operator = "equal"
104
+ target = "host"
105
+ values = [
106
+ "aaa.makn.cn",
107
+ ]
108
+ }
109
+ rule_conditions {
110
+ ignore_case = false
111
+ name = null
112
+ operator = "equal"
113
+ target = "extension"
114
+ values = [
115
+ ".txt",
116
+ ]
117
+ }
118
+ }
119
+ function_rule_conditions {
120
+ rule_conditions {
121
+ ignore_case = false
122
+ name = null
123
+ operator = "notequal"
124
+ target = "host"
125
+ values = [
126
+ "aaa.makn.cn",
127
+ ]
128
+ }
129
+ rule_conditions {
130
+ ignore_case = false
131
+ name = null
132
+ operator = "equal"
133
+ target = "extension"
134
+ values = [
135
+ ".png",
136
+ ]
137
+ }
138
+ }
139
+ }
140
+ `
141
+
142
+ const testAccTeoFunctionRuleUp = `
143
+
144
+ resource "tencentcloud_teo_function_rule" "teo_function_rule" {
145
+ function_id = "ef-txx7fnua"
146
+ remark = "bbb"
147
+ zone_id = "zone-2qtuhspy7cr6"
148
+
149
+ function_rule_conditions {
150
+ rule_conditions {
151
+ ignore_case = false
152
+ name = null
153
+ operator = "notequal"
154
+ target = "host"
155
+ values = [
156
+ "aaa.makn.cn",
157
+ ]
158
+ }
159
+ rule_conditions {
160
+ ignore_case = false
161
+ name = null
162
+ operator = "equal"
163
+ target = "extension"
164
+ values = [
165
+ ".txt",
166
+ ]
167
+ }
168
+ }
169
+ function_rule_conditions {
170
+ rule_conditions {
171
+ ignore_case = false
172
+ name = null
173
+ operator = "notequal"
174
+ target = "host"
175
+ values = [
176
+ "aaa.makn.cn",
177
+ ]
178
+ }
179
+ rule_conditions {
180
+ ignore_case = false
181
+ name = null
182
+ operator = "equal"
183
+ target = "extension"
184
+ values = [
185
+ ".png",
186
+ ]
187
+ }
188
+ }
33
189
}
34
190
`
0 commit comments