Skip to content

Commit

Permalink
Add regression test to verify issue #5 never happens again
Browse files Browse the repository at this point in the history
  • Loading branch information
timohirt committed Jul 16, 2020
1 parent 3109ecf commit e7e5872
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions hetznerdns/resource_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,57 @@ resource "hetznerdns_record" "record1" {
}
`, aZoneName, aTTL, aType, aName, aValue, aTTL)
}

func TestAccTwoRecordResources(t *testing.T) {
// aZoneName must be a valid DNS domain name with an existing TLD
aZoneName := fmt.Sprintf("%s.online", acctest.RandString(10))

aValue := "192.168.1.1"
anotherValue := "192.168.1.2"
aName := acctest.RandString(10)
anotherName := acctest.RandString(10)
aType := "A"
aTTL := 60

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccAPITokenPresent(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccRecordResourceConfigCreateTwo(aZoneName, aName, anotherName, aType, aValue, anotherValue, aTTL),
PreventDiskCleanup: true,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(
"hetznerdns_record.record1", "id"),
resource.TestCheckResourceAttrSet(
"hetznerdns_record.record2", "id"),
),
},
},
})
}

func testAccRecordResourceConfigCreateTwo(aZoneName string, aName string, anotherName string, aType string, aValue string, anotherValue string, aTTL int) string {
return fmt.Sprintf(`
resource "hetznerdns_zone" "zone1" {
name = "%s"
ttl = %d
}
resource "hetznerdns_record" "record1" {
zone_id = "${hetznerdns_zone.zone1.id}"
type = "%s"
name = "%s"
value = "%s"
ttl = %d
}
resource "hetznerdns_record" "record2" {
zone_id = "${hetznerdns_zone.zone1.id}"
type = "%s"
name = "%s"
value = "%s"
ttl = %d
}
`, aZoneName, aTTL, aType, aName, aValue, aTTL, aType, anotherName, anotherValue, aTTL)
}

0 comments on commit e7e5872

Please sign in to comment.