providers/dnsimple: handle custom domains

This commit is contained in:
Jack Pearkes 2014-07-23 20:53:02 -04:00
parent 8b2c80504e
commit 07d9bb03ec
2 changed files with 9 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package dnsimple
import (
"fmt"
"os"
"strconv"
"testing"
@ -12,6 +13,7 @@ import (
func TestAccDNSimpleRecord_Basic(t *testing.T) {
var record dnsimple.Record
domain := os.Getenv("DNSIMPLE_DOMAIN")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -19,14 +21,14 @@ func TestAccDNSimpleRecord_Basic(t *testing.T) {
CheckDestroy: testAccCheckDNSimpleRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckDNSimpleRecordConfig_basic,
Config: fmt.Sprintf(testAccCheckDNSimpleRecordConfig_basic, domain),
Check: resource.ComposeTestCheckFunc(
testAccCheckDNSimpleRecordExists("dnsimple_record.foobar", &record),
testAccCheckDNSimpleRecordAttributes(&record),
resource.TestCheckResourceAttr(
"dnsimple_record.foobar", "name", "terraform"),
resource.TestCheckResourceAttr(
"dnsimple_record.foobar", "domain", "jack.ly"),
"dnsimple_record.foobar", "domain", domain),
resource.TestCheckResourceAttr(
"dnsimple_record.foobar", "value", "192.168.0.10"),
),
@ -106,7 +108,7 @@ func testAccCheckDNSimpleRecordExists(n string, record *dnsimple.Record) resourc
const testAccCheckDNSimpleRecordConfig_basic = `
resource "dnsimple_record" "foobar" {
domain = "jack.ly"
domain = "%s"
name = "terraform"
value = "192.168.0.10"

View File

@ -73,4 +73,8 @@ func testAccPreCheck(t *testing.T) {
if v := os.Getenv("DNSIMPLE_TOKEN"); v == "" {
t.Fatal("DNSIMPLE_TOKEN must be set for acceptance tests")
}
if v := os.Getenv("DNSIMPLE_DOMAIN"); v == "" {
t.Fatal("DNSIMPLE_DOMAIN must be set for acceptance tests. The domain is used to create and destroy record against.")
}
}