github.com/teknogeek/dnscontrol@v0.2.8/models/record_test.go (about)

     1  package models
     2  
     3  import "testing"
     4  
     5  func TestKey(t *testing.T) {
     6  	var tests = []struct {
     7  		rc       RecordConfig
     8  		expected RecordKey
     9  	}{
    10  		{
    11  			RecordConfig{Type: "A", NameFQDN: "example.com"},
    12  			RecordKey{Type: "A", NameFQDN: "example.com"},
    13  		},
    14  		{
    15  			RecordConfig{Type: "R53_ALIAS", NameFQDN: "example.com"},
    16  			RecordKey{Type: "R53_ALIAS", NameFQDN: "example.com"},
    17  		},
    18  		{
    19  			RecordConfig{Type: "R53_ALIAS", NameFQDN: "example.com", R53Alias: map[string]string{"foo": "bar"}},
    20  			RecordKey{Type: "R53_ALIAS", NameFQDN: "example.com"},
    21  		},
    22  		{
    23  			RecordConfig{Type: "R53_ALIAS", NameFQDN: "example.com", R53Alias: map[string]string{"type": "AAAA"}},
    24  			RecordKey{Type: "R53_ALIAS_AAAA", NameFQDN: "example.com"},
    25  		},
    26  	}
    27  	for i, test := range tests {
    28  		actual := test.rc.Key()
    29  		if test.expected != actual {
    30  			t.Errorf("%d: Expected %s, got %s", i, test.expected, actual)
    31  		}
    32  	}
    33  }