@@ -5,12 +5,35 @@ import (
55 "strconv"
66 "testing"
77
8+ "strings"
9+
810 "github.com/digitalocean/godo"
911 "github.com/hashicorp/terraform/helper/acctest"
1012 "github.com/hashicorp/terraform/helper/resource"
1113 "github.com/hashicorp/terraform/terraform"
1214)
1315
16+ func TestDigitalOceanRecordConstructFqdn (t * testing.T ) {
17+ cases := []struct {
18+ Input , Output string
19+ }{
20+ {"www" , "www.nonexample.com" },
21+ {"dev.www" , "dev.www.nonexample.com" },
22+ {"*" , "*.nonexample.com" },
23+ {"nonexample.com" , "nonexample.com" },
24+ {"test.nonexample.com" , "test.nonexample.com" },
25+ {"test.nonexample.com." , "test.nonexample.com" },
26+ }
27+
28+ domain := "nonexample.com"
29+ for _ , tc := range cases {
30+ actual := constructFqdn (tc .Input , domain )
31+ if actual != tc .Output {
32+ t .Fatalf ("input: %s\n output: %s" , tc .Input , actual )
33+ }
34+ }
35+ }
36+
1437func TestAccDigitalOceanRecord_Basic (t * testing.T ) {
1538 var record godo.DomainRecord
1639 domain := fmt .Sprintf ("foobar-test-terraform-%s.com" , acctest .RandString (10 ))
@@ -31,6 +54,8 @@ func TestAccDigitalOceanRecord_Basic(t *testing.T) {
3154 "digitalocean_record.foobar" , "domain" , domain ),
3255 resource .TestCheckResourceAttr (
3356 "digitalocean_record.foobar" , "value" , "192.168.0.10" ),
57+ resource .TestCheckResourceAttr (
58+ "digitalocean_record.foobar" , "fqdn" , strings .Join ([]string {"terraform" , domain }, "." )),
3459 ),
3560 },
3661 },
0 commit comments