|
|
|
|
@ -5,12 +5,35 @@ import (
|
|
|
|
|
"strconv"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/digitalocean/godo"
|
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestDigitalOceanRecordConstructFqdn(t *testing.T) {
|
|
|
|
|
cases := []struct {
|
|
|
|
|
Input, Output string
|
|
|
|
|
}{
|
|
|
|
|
{"www", "www.nonexample.com"},
|
|
|
|
|
{"dev.www", "dev.www.nonexample.com"},
|
|
|
|
|
{"*", "*.nonexample.com"},
|
|
|
|
|
{"nonexample.com", "nonexample.com"},
|
|
|
|
|
{"test.nonexample.com", "test.nonexample.com"},
|
|
|
|
|
{"test.nonexample.com.", "test.nonexample.com"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
domain := "nonexample.com"
|
|
|
|
|
for _, tc := range cases {
|
|
|
|
|
actual := constructFqdn(tc.Input, domain)
|
|
|
|
|
if actual != tc.Output {
|
|
|
|
|
t.Fatalf("input: %s\noutput: %s", tc.Input, actual)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccDigitalOceanRecord_Basic(t *testing.T) {
|
|
|
|
|
var record godo.DomainRecord
|
|
|
|
|
domain := fmt.Sprintf("foobar-test-terraform-%s.com", acctest.RandString(10))
|
|
|
|
|
@ -31,6 +54,8 @@ func TestAccDigitalOceanRecord_Basic(t *testing.T) {
|
|
|
|
|
"digitalocean_record.foobar", "domain", domain),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"digitalocean_record.foobar", "value", "192.168.0.10"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"digitalocean_record.foobar", "fqdn", strings.Join([]string{"terraform", domain}, ".")),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|