Commit d2ca4518 authored by Mikio Hara's avatar Mikio Hara Committed by Russ Cox

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 <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 336c9982
......@@ -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)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment