1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Correctly group R53_ALIAS records during IncrementalDiff. (#399)

Previously, unnecessary corrections were possible if both an R53_ALIAS
pointing to an A record and to an AAAA record existed for the same label,
and map iteration over existing and desired found them in different orders.
(This is a common configuration for IPv6-enabled records.)

This commit:
 * mirrors key logic in the R53 provider
 * centralizes logic around keys in the models package
 * adds tests
This commit is contained in:
Ed Bardsley
2018-09-04 07:55:27 -07:00
committed by Craig Peterson
parent 50c126c2d4
commit 61c92c9215
4 changed files with 51 additions and 38 deletions

33
models/record_test.go Normal file
View File

@@ -0,0 +1,33 @@
package models
import "testing"
func TestKey(t *testing.T) {
var tests = []struct {
rc RecordConfig
expected RecordKey
}{
{
RecordConfig{Type: "A", Name: "@"},
RecordKey{Type: "A", Name: "@"},
},
{
RecordConfig{Type: "R53_ALIAS", Name: "@"},
RecordKey{Type: "R53_ALIAS", Name: "@"},
},
{
RecordConfig{Type: "R53_ALIAS", Name: "@", R53Alias: map[string]string{"foo": "bar"}},
RecordKey{Type: "R53_ALIAS", Name: "@"},
},
{
RecordConfig{Type: "R53_ALIAS", Name: "@", R53Alias: map[string]string{"type": "AAAA"}},
RecordKey{Type: "R53_ALIAS_AAAA", Name: "@"},
},
}
for i, test := range tests {
actual := test.rc.Key()
if test.expected != actual {
t.Errorf("%d: Expected %s, got %s", i, test.expected, actual)
}
}
}