Skip to content

Commit dddfe9e

Browse files
committed
tests: Refactor test configs
1 parent c1d6806 commit dddfe9e

File tree

1 file changed

+12
-35
lines changed

1 file changed

+12
-35
lines changed

ovh/resource_ovh_domain_zone_record_test.go

+12-35
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func TestAccOvhDomainZoneRecord_Basic(t *testing.T) {
103103
CheckDestroy: testAccCheckOvhDomainZoneRecordDestroy,
104104
Steps: []resource.TestStep{
105105
{
106-
Config: fmt.Sprintf(testAccCheckOvhDomainZoneRecordConfig_basic, zone, subdomain),
106+
Config: testAccCheckOvhDomainZoneRecordConfig_A(zone, subdomain, "192.168.0.10", 3600),
107107
Check: resource.ComposeTestCheckFunc(
108108
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
109109
resource.TestCheckResourceAttr(
@@ -131,7 +131,7 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
131131
CheckDestroy: testAccCheckOvhDomainZoneRecordDestroy,
132132
Steps: []resource.TestStep{
133133
{
134-
Config: fmt.Sprintf(testAccCheckOvhDomainZoneRecordConfig_basic, zone, subdomain),
134+
Config: testAccCheckOvhDomainZoneRecordConfig_A(zone, subdomain, "192.168.0.10", 3600),
135135
Check: resource.ComposeTestCheckFunc(
136136
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
137137
resource.TestCheckResourceAttr(
@@ -145,7 +145,7 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
145145
),
146146
},
147147
{
148-
Config: fmt.Sprintf(testAccCheckOvhDomainZoneRecordConfig_new_value_1, zone, subdomain),
148+
Config: testAccCheckOvhDomainZoneRecordConfig_A(zone, subdomain, "192.168.0.11", 3600),
149149
Check: resource.ComposeTestCheckFunc(
150150
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
151151
resource.TestCheckResourceAttr(
@@ -159,7 +159,8 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
159159
),
160160
},
161161
{
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),
163164
Check: resource.ComposeTestCheckFunc(
164165
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
165166
resource.TestCheckResourceAttr(
@@ -173,7 +174,8 @@ func TestAccOvhDomainZoneRecord_Updated(t *testing.T) {
173174
),
174175
},
175176
{
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),
177179
Check: resource.ComposeTestCheckFunc(
178180
testAccCheckOvhDomainZoneRecordExists("ovh_domain_zone_record.foobar", &record),
179181
resource.TestCheckResourceAttr(
@@ -245,38 +247,13 @@ func testAccCheckOvhDomainZoneRecordExists(n string, record *OvhDomainZoneRecord
245247
}
246248
}
247249

248-
const testAccCheckOvhDomainZoneRecordConfig_basic = `
250+
func testAccCheckOvhDomainZoneRecordConfig_A(zone, subdomain, target string, ttl int) string {
251+
return fmt.Sprintf(`
249252
resource "ovh_domain_zone_record" "foobar" {
250253
zone = "%s"
251254
subdomain = "%s"
252-
target = "192.168.0.10"
255+
target = "%s"
253256
fieldtype = "A"
254-
ttl = 3600
255-
}`
256-
257-
const testAccCheckOvhDomainZoneRecordConfig_new_value_1 = `
258-
resource "ovh_domain_zone_record" "foobar" {
259-
zone = "%s"
260-
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
257+
ttl = %d
258+
}`, zone, subdomain, target, ttl)
273259
}
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

Comments
 (0)