diff --git a/builtin/providers/digitalocean/resource_digitalocean_domain_test.go b/builtin/providers/digitalocean/resource_digitalocean_domain_test.go index 2801414ee..a5484c1e1 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_domain_test.go +++ b/builtin/providers/digitalocean/resource_digitalocean_domain_test.go @@ -5,12 +5,14 @@ import ( "testing" "github.com/digitalocean/godo" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) func TestAccDigitalOceanDomain_Basic(t *testing.T) { var domain godo.Domain + domainName := fmt.Sprintf("foobar-test-terraform-%s.com", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -18,12 +20,12 @@ func TestAccDigitalOceanDomain_Basic(t *testing.T) { CheckDestroy: testAccCheckDigitalOceanDomainDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckDigitalOceanDomainConfig_basic, + Config: fmt.Sprintf(testAccCheckDigitalOceanDomainConfig_basic, domainName), Check: resource.ComposeTestCheckFunc( testAccCheckDigitalOceanDomainExists("digitalocean_domain.foobar", &domain), - testAccCheckDigitalOceanDomainAttributes(&domain), + testAccCheckDigitalOceanDomainAttributes(&domain, domainName), resource.TestCheckResourceAttr( - "digitalocean_domain.foobar", "name", "foobar-test-terraform.com"), + "digitalocean_domain.foobar", "name", domainName), resource.TestCheckResourceAttr( "digitalocean_domain.foobar", "ip_address", "192.168.0.10"), ), @@ -51,10 +53,10 @@ func testAccCheckDigitalOceanDomainDestroy(s *terraform.State) error { return nil } -func testAccCheckDigitalOceanDomainAttributes(domain *godo.Domain) resource.TestCheckFunc { +func testAccCheckDigitalOceanDomainAttributes(domain *godo.Domain, name string) resource.TestCheckFunc { return func(s *terraform.State) error { - if domain.Name != "foobar-test-terraform.com" { + if domain.Name != name { return fmt.Errorf("Bad name: %s", domain.Name) } @@ -94,6 +96,6 @@ func testAccCheckDigitalOceanDomainExists(n string, domain *godo.Domain) resourc const testAccCheckDigitalOceanDomainConfig_basic = ` resource "digitalocean_domain" "foobar" { - name = "foobar-test-terraform.com" - ip_address = "192.168.0.10" + name = "%s" + ip_address = "192.168.0.10" }`