]> Cypherpunks repositories - gostls13.git/commitdiff
net: adjust Lookup API test cases
authorMikio Hara <mikioh.mikioh@gmail.com>
Fri, 4 Dec 2015 08:54:21 +0000 (17:54 +0900)
committerRuss Cox <rsc@golang.org>
Sat, 5 Dec 2015 06:19:47 +0000 (06:19 +0000)
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 <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/lookup_test.go

index 4a8e631027e65046d97b6199e66cdbe0c3f0d131..07b3686d50d84506f24f28667f0929223812a2fc 100644 (file)
@@ -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)
                }
        }