Skip to content

Commit 3089d18

Browse files
committed
net: fix test after 8.8.8.8 changed its reverse DNS name
Google's 8.8.8.8 DNS server used to reports its reverse DNS name as ending in ".google.com". Now it's "dns.google.". Change-Id: I7dd15f03239e5c3f202e471618ab867690cb4f9d Reviewed-on: https://go-review.googlesource.com/c/go/+/169679 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent ad8b7a7 commit 3089d18

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/net/lookup_test.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,11 @@ func TestLookupGmailTXT(t *testing.T) {
254254
}
255255
}
256256

257-
var lookupGooglePublicDNSAddrTests = []struct {
258-
addr, name string
259-
}{
260-
{"8.8.8.8", ".google.com."},
261-
{"8.8.4.4", ".google.com."},
262-
263-
{"2001:4860:4860::8888", ".google.com."},
264-
{"2001:4860:4860::8844", ".google.com."},
257+
var lookupGooglePublicDNSAddrTests = []string{
258+
"8.8.8.8",
259+
"8.8.4.4",
260+
"2001:4860:4860::8888",
261+
"2001:4860:4860::8844",
265262
}
266263

267264
func TestLookupGooglePublicDNSAddr(t *testing.T) {
@@ -273,17 +270,17 @@ func TestLookupGooglePublicDNSAddr(t *testing.T) {
273270

274271
defer dnsWaitGroup.Wait()
275272

276-
for _, tt := range lookupGooglePublicDNSAddrTests {
277-
names, err := LookupAddr(tt.addr)
273+
for _, ip := range lookupGooglePublicDNSAddrTests {
274+
names, err := LookupAddr(ip)
278275
if err != nil {
279276
t.Fatal(err)
280277
}
281278
if len(names) == 0 {
282279
t.Error("got no record")
283280
}
284281
for _, name := range names {
285-
if !strings.HasSuffix(name, tt.name) {
286-
t.Errorf("got %s; want a record containing %s", name, tt.name)
282+
if !strings.HasSuffix(name, ".google.com.") && !strings.HasSuffix(name, ".google.") {
283+
t.Errorf("got %q; want a record ending in .google.com. or .google.", name)
287284
}
288285
}
289286
}
@@ -659,8 +656,8 @@ func testDots(t *testing.T, mode string) {
659656
t.Errorf("LookupAddr(8.8.8.8): %v (mode=%v)", err, mode)
660657
} else {
661658
for _, name := range names {
662-
if !strings.HasSuffix(name, ".google.com.") {
663-
t.Errorf("LookupAddr(8.8.8.8) = %v, want names ending in .google.com. with trailing dot (mode=%v)", names, mode)
659+
if !strings.HasSuffix(name, ".google.com.") && !strings.HasSuffix(name, ".google.") {
660+
t.Errorf("LookupAddr(8.8.8.8) = %v, want names ending in .google.com or .google with trailing dot (mode=%v)", names, mode)
664661
break
665662
}
666663
}

0 commit comments

Comments
 (0)