]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix failing TestGoLookupIPOrderFallbackToFile
authorBenjamin Prosnitz <bprosnitz@google.com>
Wed, 2 Dec 2015 03:02:04 +0000 (11:02 +0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 3 Dec 2015 19:01:30 +0000 (19:01 +0000)
Change-Id: I17ef4e221e5cd0fb8dc553785248ccac59380c6f
Reviewed-on: https://go-review.googlesource.com/17321
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

src/net/dnsclient_unix.go
src/net/dnsclient_unix_test.go

index 5e963d27cc37e7d779b38fa7940286f0b2a6abd1..319011f5f6edf1364dc86fcb53f28fa712c6e5f5 100644 (file)
@@ -476,7 +476,7 @@ func goLookupIPOrder(name string, order hostLookupOrder) (addrs []IPAddr, err er
                if order == hostLookupDNSFiles {
                        addrs = goLookupIPFiles(name)
                }
-               if lastErr != nil {
+               if len(addrs) == 0 && lastErr != nil {
                        return nil, lastErr
                }
        }
index a54f7b898d9545055177984f913a7b4219bcebac..66ca4cf8ab0b1aff99844959823b89e88decaa58 100644 (file)
@@ -413,7 +413,11 @@ func TestGoLookupIPOrderFallbackToFile(t *testing.T) {
                        t.Errorf("%s: expected to successfully lookup host entry", name)
                        continue
                }
-               if got, want := addrs, []IPAddr{IPAddr{IP: IP{127, 0, 0, 1}}}; !reflect.DeepEqual(got, want) {
+               if len(addrs) != 1 {
+                       t.Errorf("%s: expected exactly one result, but got %v", name, addrs)
+                       continue
+               }
+               if got, want := addrs[0].String(), "127.1.1.1"; got != want {
                        t.Errorf("%s: address doesn't match expectation. got %v, want %v", name, got, want)
                }
        }