Skip to content

Commit 723605e

Browse files
Benjamin Prosnitzbradfitz
Benjamin Prosnitz
authored andcommitted
net: fix failing TestGoLookupIPOrderFallbackToFile
Change-Id: I17ef4e221e5cd0fb8dc553785248ccac59380c6f Reviewed-on: https://go-review.googlesource.com/17321 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]>
1 parent d5e8f4d commit 723605e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/net/dnsclient_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ func goLookupIPOrder(name string, order hostLookupOrder) (addrs []IPAddr, err er
476476
if order == hostLookupDNSFiles {
477477
addrs = goLookupIPFiles(name)
478478
}
479-
if lastErr != nil {
479+
if len(addrs) == 0 && lastErr != nil {
480480
return nil, lastErr
481481
}
482482
}

src/net/dnsclient_unix_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,11 @@ func TestGoLookupIPOrderFallbackToFile(t *testing.T) {
413413
t.Errorf("%s: expected to successfully lookup host entry", name)
414414
continue
415415
}
416-
if got, want := addrs, []IPAddr{IPAddr{IP: IP{127, 0, 0, 1}}}; !reflect.DeepEqual(got, want) {
416+
if len(addrs) != 1 {
417+
t.Errorf("%s: expected exactly one result, but got %v", name, addrs)
418+
continue
419+
}
420+
if got, want := addrs[0].String(), "127.1.1.1"; got != want {
417421
t.Errorf("%s: address doesn't match expectation. got %v, want %v", name, got, want)
418422
}
419423
}

0 commit comments

Comments
 (0)