github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/ultradns/resource_ultradns_rdpool_test.go (about)

     1  package ultradns
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/Ensighten/udnssdk"
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestAccUltradnsRdpool(t *testing.T) {
    12  	var record udnssdk.RRSet
    13  	domain := "ultradns.phinze.com"
    14  
    15  	resource.Test(t, resource.TestCase{
    16  		PreCheck:     func() { testAccPreCheck(t) },
    17  		Providers:    testAccProviders,
    18  		CheckDestroy: testAccRdpoolCheckDestroy,
    19  		Steps: []resource.TestStep{
    20  			resource.TestStep{
    21  				Config: fmt.Sprintf(testCfgRdpoolMinimal, domain),
    22  				Check: resource.ComposeTestCheckFunc(
    23  					testAccCheckUltradnsRecordExists("ultradns_rdpool.it", &record),
    24  					// Specified
    25  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "zone", domain),
    26  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "name", "test-rdpool-minimal"),
    27  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "ttl", "300"),
    28  
    29  					// hashRdatas(): 10.6.0.1 -> 2847814707
    30  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "rdata.2847814707.host", "10.6.0.1"),
    31  					// Defaults
    32  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "description", "Minimal RD Pool"),
    33  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "rdata.2847814707.priority", "1"),
    34  					// Generated
    35  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "id", "test-rdpool-minimal.ultradns.phinze.com"),
    36  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "hostname", "test-rdpool-minimal.ultradns.phinze.com."),
    37  				),
    38  			},
    39  			resource.TestStep{
    40  				Config: fmt.Sprintf(testCfgRdpoolMaximal, domain),
    41  				Check: resource.ComposeTestCheckFunc(
    42  					testAccCheckUltradnsRecordExists("ultradns_rdpool.it", &record),
    43  					// Specified
    44  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "zone", domain),
    45  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "name", "test-rdpool-maximal"),
    46  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "ttl", "300"),
    47  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "description", "traffic controller pool with all settings tuned"),
    48  
    49  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "act_on_probes", "false"),
    50  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "max_to_lb", "2"),
    51  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "run_probes", "false"),
    52  
    53  					// hashRdatas(): 10.6.1.1 -> 2826722820
    54  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "rdata.2826722820.host", "10.6.1.1"),
    55  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "rdata.2826722820.priority", "1"),
    56  
    57  					// hashRdatas(): 10.6.1.2 -> 829755326
    58  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "rdata.829755326.host", "10.6.1.2"),
    59  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "rdata.829755326.priority", "2"),
    60  
    61  					// Generated
    62  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "id", "test-rdpool-maximal.ultradns.phinze.com"),
    63  					resource.TestCheckResourceAttr("ultradns_rdpool.it", "hostname", "test-rdpool-maximal.ultradns.phinze.com."),
    64  				),
    65  			},
    66  		},
    67  	})
    68  }
    69  
    70  const testCfgRdpoolMinimal = `
    71  resource "ultradns_rdpool" "it" {
    72    zone        = "%s"
    73    name        = "test-rdpool-minimal"
    74    ttl         = 300
    75    description = "Minimal RD Pool"
    76  
    77    rdata {
    78      host = "10.6.0.1"
    79    }
    80  }
    81  `
    82  
    83  const testCfgRdpoolMaximal = `
    84  resource "ultradns_rdpool" "it" {
    85    zone        = "%s"
    86    name        = "test-rdpool-maximal"
    87    order       = "ROUND_ROBIN"
    88    ttl         = 300
    89    description = "traffic controller pool with all settings tuned"
    90    rdata {
    91      host = "10.6.1.1"
    92      priority       = 1
    93    }
    94  
    95    rdata {
    96      host = "10.6.1.2"
    97      priority       = 2
    98    }
    99  }
   100  `