mirror of https://github.com/golang/go.git
net: do not modify shared test variable in TestDNSReadConfig
Fixes #56542
Change-Id: I294856f8fb4d49393310ec92ab40fb7d841b6570
GitHub-Last-Rev: a4563400af
GitHub-Pull-Request: golang/go#56545
Reviewed-on: https://go-review.googlesource.com/c/go/+/447198
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
5c0d314adc
commit
0b76e326bb
|
|
@ -176,16 +176,17 @@ func TestDNSReadConfig(t *testing.T) {
|
||||||
getHostname = func() (string, error) { return "host.domain.local", nil }
|
getHostname = func() (string, error) { return "host.domain.local", nil }
|
||||||
|
|
||||||
for _, tt := range dnsReadConfigTests {
|
for _, tt := range dnsReadConfigTests {
|
||||||
if len(tt.want.search) == 0 {
|
want := *tt.want
|
||||||
tt.want.search = append(tt.want.search, dnsDefaultSearch()...)
|
if len(want.search) == 0 {
|
||||||
|
want.search = dnsDefaultSearch()
|
||||||
}
|
}
|
||||||
conf := dnsReadConfig(tt.name)
|
conf := dnsReadConfig(tt.name)
|
||||||
if conf.err != nil {
|
if conf.err != nil {
|
||||||
t.Fatal(conf.err)
|
t.Fatal(conf.err)
|
||||||
}
|
}
|
||||||
conf.mtime = time.Time{}
|
conf.mtime = time.Time{}
|
||||||
if !reflect.DeepEqual(conf, tt.want) {
|
if !reflect.DeepEqual(conf, &want) {
|
||||||
t.Errorf("%s:\ngot: %+v\nwant: %+v", tt.name, conf, tt.want)
|
t.Errorf("%s:\ngot: %+v\nwant: %+v", tt.name, conf, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -272,8 +273,13 @@ func TestDNSNameLength(t *testing.T) {
|
||||||
t.Fatal(conf.err)
|
t.Fatal(conf.err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suffixList := tt.want.search
|
||||||
|
if len(suffixList) == 0 {
|
||||||
|
suffixList = dnsDefaultSearch()
|
||||||
|
}
|
||||||
|
|
||||||
var shortestSuffix int
|
var shortestSuffix int
|
||||||
for _, suffix := range tt.want.search {
|
for _, suffix := range suffixList {
|
||||||
if shortestSuffix == 0 || len(suffix) < shortestSuffix {
|
if shortestSuffix == 0 || len(suffix) < shortestSuffix {
|
||||||
shortestSuffix = len(suffix)
|
shortestSuffix = len(suffix)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue