Merge branch 'master' of https://github.com/alkersan/terraform into alkersan-master

This commit is contained in:
James Nugent 2016-02-22 13:54:24 -05:00
commit be20d0166a
2 changed files with 32 additions and 3 deletions

View File

@ -91,17 +91,19 @@ type errorResponse struct {
ErrorMsg string `json:"error"`
}
const idSeparator string = ":::"
func (record *Record) Id() string {
return fmt.Sprintf("%s-%s", record.Name, record.Type)
return record.Name + idSeparator + record.Type
}
func (rrSet *ResourceRecordSet) Id() string {
return fmt.Sprintf("%s-%s", rrSet.Name, rrSet.Type)
return rrSet.Name + idSeparator + rrSet.Type
}
// Returns name and type of record or record set based on it's ID
func parseId(recId string) (string, string, error) {
s := strings.Split(recId, "-")
s := strings.Split(recId, idSeparator)
if len(s) == 2 {
return s[0], s[1], nil
} else {

View File

@ -24,6 +24,23 @@ func TestAccPDNSRecord_A(t *testing.T) {
})
}
func TestAccPDNSRecord_WithCount(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
{
Config: testPDNSRecordConfigHyphenedWithCount,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-counted.0"),
testAccCheckPDNSRecordExists("powerdns_record.test-counted.1"),
),
},
},
})
}
func TestAccPDNSRecord_AAAA(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -262,6 +279,16 @@ resource "powerdns_record" "test-a" {
records = [ "1.1.1.1", "2.2.2.2" ]
}`
const testPDNSRecordConfigHyphenedWithCount = `
resource "powerdns_record" "test-counted" {
count = "2"
zone = "sysa.xyz"
name = "redis-${count.index}.sysa.xyz"
type = "A"
ttl = 60
records = [ "1.1.1.${count.index}" ]
}`
const testPDNSRecordConfigAAAA = `
resource "powerdns_record" "test-aaaa" {
zone = "sysa.xyz"