From d2ca451873f6548f43d272c675d1b114165c394d Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Fri, 4 Dec 2015 17:54:21 +0900 Subject: [PATCH] net: adjust Lookup API test cases This change makes existing Lookup API test cases conform to the new return value form that all the Lookup APIs except LookupTXT must return a single or multiple absolute domain names. Updates #12189. Fixes #12193. Change-Id: I03ca09be5bff80e818fbcdc26039daa33d5440a8 Reviewed-on: https://go-review.googlesource.com/17411 Run-TryBot: Mikio Hara TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/net/lookup_test.go | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/net/lookup_test.go b/src/net/lookup_test.go index 4a8e631027..07b3686d50 100644 --- a/src/net/lookup_test.go +++ b/src/net/lookup_test.go @@ -38,21 +38,21 @@ var lookupGoogleSRVTests = []struct { }{ { "xmpp-server", "tcp", "google.com", - "google.com", "google.com", + "google.com.", "google.com.", }, { "xmpp-server", "tcp", "google.com.", - "google.com", "google.com", + "google.com.", "google.com.", }, // non-standard back door { "", "", "_xmpp-server._tcp.google.com", - "google.com", "google.com", + "google.com.", "google.com.", }, { "", "", "_xmpp-server._tcp.google.com.", - "google.com", "google.com", + "google.com.", "google.com.", }, } @@ -72,11 +72,11 @@ func TestLookupGoogleSRV(t *testing.T) { if len(srvs) == 0 { t.Error("got no record") } - if !strings.HasSuffix(cname, tt.cname) && !strings.HasSuffix(cname, tt.cname+".") { + if !strings.HasSuffix(cname, tt.cname) { t.Errorf("got %s; want %s", cname, tt.cname) } for _, srv := range srvs { - if !strings.HasSuffix(srv.Target, tt.target) && !strings.HasSuffix(srv.Target, tt.target+".") { + if !strings.HasSuffix(srv.Target, tt.target) { t.Errorf("got %v; want a record containing %s", srv, tt.target) } } @@ -86,8 +86,8 @@ func TestLookupGoogleSRV(t *testing.T) { var lookupGmailMXTests = []struct { name, host string }{ - {"gmail.com", "google.com"}, - {"gmail.com.", "google.com"}, + {"gmail.com", "google.com."}, + {"gmail.com.", "google.com."}, } func TestLookupGmailMX(t *testing.T) { @@ -107,7 +107,7 @@ func TestLookupGmailMX(t *testing.T) { t.Error("got no record") } for _, mx := range mxs { - if !strings.HasSuffix(mx.Host, tt.host) && !strings.HasSuffix(mx.Host, tt.host+".") { + if !strings.HasSuffix(mx.Host, tt.host) { t.Errorf("got %v; want a record containing %s", mx, tt.host) } } @@ -117,8 +117,8 @@ func TestLookupGmailMX(t *testing.T) { var lookupGmailNSTests = []struct { name, host string }{ - {"gmail.com", "google.com"}, - {"gmail.com.", "google.com"}, + {"gmail.com", "google.com."}, + {"gmail.com.", "google.com."}, } func TestLookupGmailNS(t *testing.T) { @@ -138,7 +138,7 @@ func TestLookupGmailNS(t *testing.T) { t.Error("got no record") } for _, ns := range nss { - if !strings.HasSuffix(ns.Host, tt.host) && !strings.HasSuffix(ns.Host, tt.host+".") { + if !strings.HasSuffix(ns.Host, tt.host) { t.Errorf("got %v; want a record containing %s", ns, tt.host) } } @@ -179,10 +179,11 @@ func TestLookupGmailTXT(t *testing.T) { var lookupGooglePublicDNSAddrTests = []struct { addr, name string }{ - {"8.8.8.8", ".google.com"}, - {"8.8.4.4", ".google.com"}, - {"2001:4860:4860::8888", ".google.com"}, - {"2001:4860:4860::8844", ".google.com"}, + {"8.8.8.8", ".google.com."}, + {"8.8.4.4", ".google.com."}, + + {"2001:4860:4860::8888", ".google.com."}, + {"2001:4860:4860::8844", ".google.com."}, } func TestLookupGooglePublicDNSAddr(t *testing.T) { @@ -202,7 +203,7 @@ func TestLookupGooglePublicDNSAddr(t *testing.T) { t.Error("got no record") } for _, name := range names { - if !strings.HasSuffix(name, tt.name) && !strings.HasSuffix(name, tt.name+".") { + if !strings.HasSuffix(name, tt.name) { t.Errorf("got %s; want a record containing %s", name, tt.name) } } @@ -236,8 +237,8 @@ func TestLookupIPv6LinkLocalAddr(t *testing.T) { var lookupIANACNAMETests = []struct { name, cname string }{ - {"www.iana.org", "icann.org"}, - {"www.iana.org.", "icann.org"}, + {"www.iana.org", "icann.org."}, + {"www.iana.org.", "icann.org."}, } func TestLookupIANACNAME(t *testing.T) { @@ -253,7 +254,7 @@ func TestLookupIANACNAME(t *testing.T) { if err != nil { t.Fatal(err) } - if !strings.HasSuffix(cname, tt.cname) && !strings.HasSuffix(cname, tt.cname+".") { + if !strings.HasSuffix(cname, tt.cname) { t.Errorf("got %s; want a record containing %s", cname, tt.cname) } } -- 2.50.0