Skip to content

Commit

Permalink
net: adjust Lookup API test cases
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cixtor authored and rsc committed Dec 5, 2015
1 parent 336c998 commit d2ca451
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/net/lookup_test.go
Expand Up @@ -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.",
},
}

Expand All @@ -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)
}
}
Expand All @@ -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) {
Expand All @@ -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)
}
}
Expand All @@ -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) {
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}
}
Expand Down

0 comments on commit d2ca451

Please sign in to comment.