diff options
author | 2018-03-13 00:06:50 -0700 | |
---|---|---|
committer | 2018-03-13 07:06:50 +0000 | |
commit | 3e3d8cc845b8e072efc75043c9aa3df318ec3bf3 (patch) | |
tree | e14c86315bfea8789c8a41260081f181415f655b /plugin/route53 | |
parent | 0daa03a81f87088afe9f3e8eb9aa8341acd9c65b (diff) | |
download | coredns-3e3d8cc845b8e072efc75043c9aa3df318ec3bf3.tar.gz coredns-3e3d8cc845b8e072efc75043c9aa3df318ec3bf3.tar.zst coredns-3e3d8cc845b8e072efc75043c9aa3df318ec3bf3.zip |
Fix incorrect test case in rout53 plugin (#1603)
While looking into route53 plugin I notice the test case
was incorrect and does not really test the reply. This
fix fixes the issue in the test.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin/route53')
-rw-r--r-- | plugin/route53/route53_test.go | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/plugin/route53/route53_test.go b/plugin/route53/route53_test.go index 50f3c0c8f..ed118a945 100644 --- a/plugin/route53/route53_test.go +++ b/plugin/route53/route53_test.go @@ -18,12 +18,19 @@ type mockedRoute53 struct { } func (mockedRoute53) ListResourceRecordSets(input *route53.ListResourceRecordSetsInput) (*route53.ListResourceRecordSetsOutput, error) { + var value string + switch aws.StringValue(input.StartRecordType) { + case "A": + value = "10.2.3.4" + case "AAAA": + value = "2001:db8:85a3::8a2e:370:7334" + } return &route53.ListResourceRecordSetsOutput{ ResourceRecordSets: []*route53.ResourceRecordSet{ { ResourceRecords: []*route53.ResourceRecord{ { - Value: aws.String("10.2.3.4"), + Value: aws.String(value), }, }, }, @@ -49,7 +56,14 @@ func TestRoute53(t *testing.T) { qname: "example.org", qtype: dns.TypeA, expectedCode: dns.RcodeSuccess, - expectedReply: []string{"example.org."}, + expectedReply: []string{"10.2.3.4"}, + expectedErr: nil, + }, + { + qname: "example.org", + qtype: dns.TypeAAAA, + expectedCode: dns.RcodeSuccess, + expectedReply: []string{"2001:db8:85a3::8a2e:370:7334"}, expectedErr: nil, }, } @@ -71,7 +85,13 @@ func TestRoute53(t *testing.T) { } if len(tc.expectedReply) != 0 { for i, expected := range tc.expectedReply { - actual := rec.Msg.Answer[i].Header().Name + var actual string + switch tc.qtype { + case dns.TypeA: + actual = rec.Msg.Answer[i].(*dns.A).A.String() + case dns.TypeAAAA: + actual = rec.Msg.Answer[i].(*dns.AAAA).AAAA.String() + } if actual != expected { t.Errorf("Test %d: Expected answer %s, but got %s", i, expected, actual) } |