Fix route53 stub matching logic: match name & type

pull/6/head
Justin Santa Barbara 2016-07-15 10:57:09 -04:00
parent 6463a220ee
commit 756c17315b
2 changed files with 8 additions and 7 deletions

View File

@ -76,17 +76,18 @@ func (r *Route53APIStub) ChangeResourceRecordSets(input *route53.ChangeResourceR
}
for _, change := range input.ChangeBatch.Changes {
key := *change.ResourceRecordSet.Name + "::" + *change.ResourceRecordSet.Type
switch *change.Action {
case route53.ChangeActionCreate:
if _, found := recordSets[*change.ResourceRecordSet.Name]; found {
return nil, fmt.Errorf("Attempt to create duplicate rrset %s", *change.ResourceRecordSet.Name) // TODO: Return AWS errors with codes etc
if _, found := recordSets[key]; found {
return nil, fmt.Errorf("Attempt to create duplicate rrset %s", key) // TODO: Return AWS errors with codes etc
}
recordSets[*change.ResourceRecordSet.Name] = append(recordSets[*change.ResourceRecordSet.Name], change.ResourceRecordSet)
recordSets[key] = append(recordSets[key], change.ResourceRecordSet)
case route53.ChangeActionDelete:
if _, found := recordSets[*change.ResourceRecordSet.Name]; !found {
return nil, fmt.Errorf("Attempt to delete non-existant rrset %s", *change.ResourceRecordSet.Name) // TODO: Check other fields too
if _, found := recordSets[key]; !found {
return nil, fmt.Errorf("Attempt to delete non-existant rrset %s", key) // TODO: Check other fields too
}
delete(recordSets, *change.ResourceRecordSet.Name)
delete(recordSets, key)
case route53.ChangeActionUpsert:
// TODO - not used yet
}

View File

@ -89,7 +89,7 @@ func CommonTestResourceRecordSetsDifferentTypes(t *testing.T, zone dnsprovider.Z
// Add the resource with the same name but different type
err := sets.StartChangeset().Add(cnameRrset).Apply()
if err != nil {
t.Errorf("Failed to add resource record set %v: %v", rrset, cnameRrset, err)
t.Errorf("Failed to add resource record set %v: %v", cnameRrset, err)
}
defer sets.StartChangeset().Remove(cnameRrset).Apply()