@@ -77,11 +77,57 @@ var (
77
77
resolver : & mockHostnameResolver {},
78
78
},
79
79
{
80
- testName : "multiple srv records from srv lookup" ,
80
+ testName : "multiple SRV records from SRV lookup" ,
81
81
addr : "_test._tcp.mycompany.com" ,
82
82
qtype : SRV ,
83
83
expectedResult : []string {"192.168.0.1:8080" , "192.168.0.2:8081" },
84
84
expectedErr : nil ,
85
+ resolver : & mockHostnameResolver {
86
+ resultSRVs : map [string ][]* net.SRV {
87
+ "_test._tcp.mycompany.com" : {
88
+ & net.SRV {Target : "alt1.mycompany.com." , Port : 8080 },
89
+ & net.SRV {Target : "alt2.mycompany.com." , Port : 8081 },
90
+ },
91
+ },
92
+ resultIPs : map [string ][]net.IPAddr {
93
+ "alt1.mycompany.com." : {net.IPAddr {IP : net .ParseIP ("192.168.0.1" )}},
94
+ "alt2.mycompany.com." : {net.IPAddr {IP : net .ParseIP ("192.168.0.2" )}},
95
+ },
96
+ },
97
+ },
98
+ {
99
+ testName : "multiple SRV records from SRV lookup with specified port" ,
100
+ addr : "_test._tcp.mycompany.com:8082" ,
101
+ qtype : SRV ,
102
+ expectedResult : []string {"192.168.0.1:8082" , "192.168.0.2:8082" },
103
+ expectedErr : nil ,
104
+ resolver : & mockHostnameResolver {
105
+ resultSRVs : map [string ][]* net.SRV {
106
+ "_test._tcp.mycompany.com" : {
107
+ & net.SRV {Target : "alt1.mycompany.com." , Port : 8080 },
108
+ & net.SRV {Target : "alt2.mycompany.com." , Port : 8081 },
109
+ },
110
+ },
111
+ resultIPs : map [string ][]net.IPAddr {
112
+ "alt1.mycompany.com." : {net.IPAddr {IP : net .ParseIP ("192.168.0.1" )}},
113
+ "alt2.mycompany.com." : {net.IPAddr {IP : net .ParseIP ("192.168.0.2" )}},
114
+ },
115
+ },
116
+ },
117
+ {
118
+ testName : "error from SRV resolver" ,
119
+ addr : "_test._tcp.mycompany.com" ,
120
+ qtype : SRV ,
121
+ expectedResult : nil ,
122
+ expectedErr : errors .Wrapf (errorFromResolver , "lookup SRV records \" _test._tcp.mycompany.com\" " ),
123
+ resolver : & mockHostnameResolver {err : errorFromResolver },
124
+ },
125
+ {
126
+ testName : "multiple SRV records from SRV no A lookup" ,
127
+ addr : "_test._tcp.mycompany.com" ,
128
+ qtype : SRVNoA ,
129
+ expectedResult : []string {"192.168.0.1:8080" , "192.168.0.2:8081" },
130
+ expectedErr : nil ,
85
131
resolver : & mockHostnameResolver {
86
132
resultSRVs : map [string ][]* net.SRV {
87
133
"_test._tcp.mycompany.com" : {
92
138
},
93
139
},
94
140
{
95
- testName : "multiple srv records from srv lookup" ,
141
+ testName : "multiple SRV records from SRV no A lookup with specified port " ,
96
142
addr : "_test._tcp.mycompany.com:8082" ,
97
- qtype : SRV ,
143
+ qtype : SRVNoA ,
98
144
expectedResult : []string {"192.168.0.1:8082" , "192.168.0.2:8082" },
99
145
expectedErr : nil ,
100
146
resolver : & mockHostnameResolver {
@@ -107,7 +153,7 @@ var (
107
153
},
108
154
},
109
155
{
110
- testName : "error from SRV resolver " ,
156
+ testName : "error from SRV no A lookup " ,
111
157
addr : "_test._tcp.mycompany.com" ,
112
158
qtype : SRV ,
113
159
expectedResult : nil ,
0 commit comments