mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	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>
This commit is contained in:
		| @@ -18,12 +18,19 @@ type mockedRoute53 struct { | |||||||
| } | } | ||||||
|  |  | ||||||
| func (mockedRoute53) ListResourceRecordSets(input *route53.ListResourceRecordSetsInput) (*route53.ListResourceRecordSetsOutput, error) { | 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{ | 	return &route53.ListResourceRecordSetsOutput{ | ||||||
| 		ResourceRecordSets: []*route53.ResourceRecordSet{ | 		ResourceRecordSets: []*route53.ResourceRecordSet{ | ||||||
| 			{ | 			{ | ||||||
| 				ResourceRecords: []*route53.ResourceRecord{ | 				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", | 			qname:         "example.org", | ||||||
| 			qtype:         dns.TypeA, | 			qtype:         dns.TypeA, | ||||||
| 			expectedCode:  dns.RcodeSuccess, | 			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, | 			expectedErr:   nil, | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
| @@ -71,7 +85,13 @@ func TestRoute53(t *testing.T) { | |||||||
| 		} | 		} | ||||||
| 		if len(tc.expectedReply) != 0 { | 		if len(tc.expectedReply) != 0 { | ||||||
| 			for i, expected := range tc.expectedReply { | 			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 { | 				if actual != expected { | ||||||
| 					t.Errorf("Test %d: Expected answer %s, but got %s", i, expected, actual) | 					t.Errorf("Test %d: Expected answer %s, but got %s", i, expected, actual) | ||||||
| 				} | 				} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user