Tests different cases for a user's dial target that specifies a non-empty authority (or Host field of the URL).
(t *testing.T)
| 1123 | // Tests different cases for a user's dial target that specifies a non-empty |
| 1124 | // authority (or Host field of the URL). |
| 1125 | func (s) TestCustomAuthority(t *testing.T) { |
| 1126 | tests := []struct { |
| 1127 | name string |
| 1128 | authority string |
| 1129 | wantAuthority string |
| 1130 | wantBuildErr bool |
| 1131 | }{ |
| 1132 | { |
| 1133 | name: "authority with default DNS port", |
| 1134 | authority: "4.3.2.1:53", |
| 1135 | wantAuthority: "4.3.2.1:53", |
| 1136 | }, |
| 1137 | { |
| 1138 | name: "authority with non-default DNS port", |
| 1139 | authority: "4.3.2.1:123", |
| 1140 | wantAuthority: "4.3.2.1:123", |
| 1141 | }, |
| 1142 | { |
| 1143 | name: "authority with no port", |
| 1144 | authority: "4.3.2.1", |
| 1145 | wantAuthority: "4.3.2.1:53", |
| 1146 | }, |
| 1147 | { |
| 1148 | name: "ipv6 authority with brackets and no port", |
| 1149 | authority: "[::1]", |
| 1150 | wantAuthority: "[::1]:53", |
| 1151 | }, |
| 1152 | { |
| 1153 | name: "ipv6 authority with brackets and non-default DNS port", |
| 1154 | authority: "[::1]:123", |
| 1155 | wantAuthority: "[::1]:123", |
| 1156 | }, |
| 1157 | { |
| 1158 | name: "host name with no port", |
| 1159 | authority: "dnsserver.com", |
| 1160 | wantAuthority: "dnsserver.com:53", |
| 1161 | }, |
| 1162 | { |
| 1163 | name: "no host port and non-default port", |
| 1164 | authority: ":123", |
| 1165 | wantAuthority: "localhost:123", |
| 1166 | }, |
| 1167 | { |
| 1168 | name: "only colon", |
| 1169 | authority: ":", |
| 1170 | wantAuthority: "", |
| 1171 | wantBuildErr: true, |
| 1172 | }, |
| 1173 | { |
| 1174 | name: "ipv6 name ending in colon", |
| 1175 | authority: "[::1]:", |
| 1176 | wantAuthority: "", |
| 1177 | wantBuildErr: true, |
| 1178 | }, |
| 1179 | { |
| 1180 | name: "host name ending in colon", |
| 1181 | authority: "dnsserver.com:", |
| 1182 | wantAuthority: "", |
nothing calls this directly
no test coverage detected