diff --git a/src/net/dnsconfig_unix_test.go b/src/net/dnsconfig_unix_test.go index 9be751f2e3e7c..0aae2ba85b8c3 100644 --- a/src/net/dnsconfig_unix_test.go +++ b/src/net/dnsconfig_unix_test.go @@ -176,16 +176,17 @@ func TestDNSReadConfig(t *testing.T) { getHostname = func() (string, error) { return "host.domain.local", nil } for _, tt := range dnsReadConfigTests { - if len(tt.want.search) == 0 { - tt.want.search = append(tt.want.search, dnsDefaultSearch()...) + want := *tt.want + if len(want.search) == 0 { + want.search = dnsDefaultSearch() } conf := dnsReadConfig(tt.name) if conf.err != nil { t.Fatal(conf.err) } conf.mtime = time.Time{} - if !reflect.DeepEqual(conf, tt.want) { - t.Errorf("%s:\ngot: %+v\nwant: %+v", tt.name, conf, tt.want) + if !reflect.DeepEqual(conf, &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) } + suffixList := tt.want.search + if len(suffixList) == 0 { + suffixList = dnsDefaultSearch() + } + var shortestSuffix int - for _, suffix := range tt.want.search { + for _, suffix := range suffixList { if shortestSuffix == 0 || len(suffix) < shortestSuffix { shortestSuffix = len(suffix) }