@@ -103,7 +103,7 @@ func TestAccOvhDomainZoneRecord_Basic(t *testing.T) {
103
103
CheckDestroy : testAccCheckOvhDomainZoneRecordDestroy ,
104
104
Steps : []resource.TestStep {
105
105
{
106
- Config : fmt . Sprintf ( testAccCheckOvhDomainZoneRecordConfig_basic , zone , subdomain ),
106
+ Config : testAccCheckOvhDomainZoneRecordConfig_A ( zone , subdomain , "192.168.0.10" , 3600 ),
107
107
Check : resource .ComposeTestCheckFunc (
108
108
testAccCheckOvhDomainZoneRecordExists ("ovh_domain_zone_record.foobar" , & record ),
109
109
resource .TestCheckResourceAttr (
@@ -131,7 +131,7 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
131
131
CheckDestroy : testAccCheckOvhDomainZoneRecordDestroy ,
132
132
Steps : []resource.TestStep {
133
133
{
134
- Config : fmt . Sprintf ( testAccCheckOvhDomainZoneRecordConfig_basic , zone , subdomain ),
134
+ Config : testAccCheckOvhDomainZoneRecordConfig_A ( zone , subdomain , "192.168.0.10" , 3600 ),
135
135
Check : resource .ComposeTestCheckFunc (
136
136
testAccCheckOvhDomainZoneRecordExists ("ovh_domain_zone_record.foobar" , & record ),
137
137
resource .TestCheckResourceAttr (
@@ -145,7 +145,7 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
145
145
),
146
146
},
147
147
{
148
- Config : fmt . Sprintf ( testAccCheckOvhDomainZoneRecordConfig_new_value_1 , zone , subdomain ),
148
+ Config : testAccCheckOvhDomainZoneRecordConfig_A ( zone , subdomain , "192.168.0.11" , 3600 ),
149
149
Check : resource .ComposeTestCheckFunc (
150
150
testAccCheckOvhDomainZoneRecordExists ("ovh_domain_zone_record.foobar" , & record ),
151
151
resource .TestCheckResourceAttr (
@@ -159,7 +159,8 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
159
159
),
160
160
},
161
161
{
162
- Config : fmt .Sprintf (testAccCheckOvhDomainZoneRecordConfig_new_value_2 , zone , subdomain ),
162
+ Config : testAccCheckOvhDomainZoneRecordConfig_A (zone , fmt .Sprintf ("%s2" , subdomain ),
163
+ "192.168.0.11" , 3600 ),
163
164
Check : resource .ComposeTestCheckFunc (
164
165
testAccCheckOvhDomainZoneRecordExists ("ovh_domain_zone_record.foobar" , & record ),
165
166
resource .TestCheckResourceAttr (
@@ -173,7 +174,8 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
173
174
),
174
175
},
175
176
{
176
- Config : fmt .Sprintf (testAccCheckOvhDomainZoneRecordConfig_new_value_3 , zone , subdomain ),
177
+ Config : testAccCheckOvhDomainZoneRecordConfig_A (zone , fmt .Sprintf ("%s3" , subdomain ),
178
+ "192.168.0.13" , 3604 ),
177
179
Check : resource .ComposeTestCheckFunc (
178
180
testAccCheckOvhDomainZoneRecordExists ("ovh_domain_zone_record.foobar" , & record ),
179
181
resource .TestCheckResourceAttr (
@@ -190,6 +192,52 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
190
192
})
191
193
}
192
194
195
+ func TestAccOvhDomainZoneRecord_updateType (t * testing.T ) {
196
+ record := OvhDomainZoneRecord {}
197
+ zone := os .Getenv ("OVH_ZONE" )
198
+ subdomain := acctest .RandomWithPrefix (test_prefix )
199
+
200
+ resource .Test (t , resource.TestCase {
201
+ PreCheck : func () { testAccPreCheck (t ) },
202
+ Providers : testAccProviders ,
203
+ CheckDestroy : testAccCheckOvhDomainZoneRecordDestroy ,
204
+ Steps : []resource.TestStep {
205
+ {
206
+ Config : testAccCheckOvhDomainZoneRecordConfig_A (zone , subdomain , "192.168.0.1" , 3600 ),
207
+ Check : resource .ComposeTestCheckFunc (
208
+ testAccCheckOvhDomainZoneRecordExists ("ovh_domain_zone_record.foobar" , & record ),
209
+ resource .TestCheckResourceAttr (
210
+ "ovh_domain_zone_record.foobar" , "subdomain" , subdomain ),
211
+ resource .TestCheckResourceAttr (
212
+ "ovh_domain_zone_record.foobar" , "zone" , zone ),
213
+ resource .TestCheckResourceAttr (
214
+ "ovh_domain_zone_record.foobar" , "target" , "192.168.0.1" ),
215
+ resource .TestCheckResourceAttr (
216
+ "ovh_domain_zone_record.foobar" , "fieldtype" , "A" ),
217
+ resource .TestCheckResourceAttr (
218
+ "ovh_domain_zone_record.foobar" , "ttl" , "3600" ),
219
+ ),
220
+ },
221
+ {
222
+ Config : testAccCheckOvhDomainZoneRecordConfig_CNAME (zone , subdomain , "google.com." , 3600 ),
223
+ Check : resource .ComposeTestCheckFunc (
224
+ testAccCheckOvhDomainZoneRecordExists ("ovh_domain_zone_record.foobar" , & record ),
225
+ resource .TestCheckResourceAttr (
226
+ "ovh_domain_zone_record.foobar" , "subdomain" , subdomain ),
227
+ resource .TestCheckResourceAttr (
228
+ "ovh_domain_zone_record.foobar" , "zone" , zone ),
229
+ resource .TestCheckResourceAttr (
230
+ "ovh_domain_zone_record.foobar" , "target" , "google.com." ),
231
+ resource .TestCheckResourceAttr (
232
+ "ovh_domain_zone_record.foobar" , "fieldtype" , "CNAME" ),
233
+ resource .TestCheckResourceAttr (
234
+ "ovh_domain_zone_record.foobar" , "ttl" , "3600" ),
235
+ ),
236
+ },
237
+ },
238
+ })
239
+ }
240
+
193
241
func testAccCheckOvhDomainZoneRecordDestroy (s * terraform.State ) error {
194
242
provider := testAccProvider .Meta ().(* Config )
195
243
zone := os .Getenv ("OVH_ZONE" )
@@ -245,38 +293,24 @@ func testAccCheckOvhDomainZoneRecordExists(n string, record *OvhDomainZoneRecord
245
293
}
246
294
}
247
295
248
- const testAccCheckOvhDomainZoneRecordConfig_basic = `
296
+ func testAccCheckOvhDomainZoneRecordConfig_A (zone , subdomain , target string , ttl int ) string {
297
+ return fmt .Sprintf (`
249
298
resource "ovh_domain_zone_record" "foobar" {
250
299
zone = "%s"
251
300
subdomain = "%s"
252
- target = "192.168.0.10 "
301
+ target = "%s "
253
302
fieldtype = "A"
254
- ttl = 3600
255
- }`
303
+ ttl = %d
304
+ }` , zone , subdomain , target , ttl )
305
+ }
256
306
257
- const testAccCheckOvhDomainZoneRecordConfig_new_value_1 = `
307
+ func testAccCheckOvhDomainZoneRecordConfig_CNAME (zone , subdomain , target string , ttl int ) string {
308
+ return fmt .Sprintf (`
258
309
resource "ovh_domain_zone_record" "foobar" {
259
310
zone = "%s"
260
311
subdomain = "%s"
261
- target = "192.168.0.11"
262
- fieldtype = "A"
263
- ttl = 3600
264
- }
265
- `
266
- const testAccCheckOvhDomainZoneRecordConfig_new_value_2 = `
267
- resource "ovh_domain_zone_record" "foobar" {
268
- zone = "%s"
269
- subdomain = "%s2"
270
- target = "192.168.0.11"
271
- fieldtype = "A"
272
- ttl = 3600
312
+ target = "%s"
313
+ fieldtype = "CNAME"
314
+ ttl = %d
315
+ }` , zone , subdomain , target , ttl )
273
316
}
274
- `
275
- const testAccCheckOvhDomainZoneRecordConfig_new_value_3 = `
276
- resource "ovh_domain_zone_record" "foobar" {
277
- zone = "%s"
278
- subdomain = "%s3"
279
- target = "192.168.0.13"
280
- fieldtype = "A"
281
- ttl = 3604
282
- }`
0 commit comments