diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-10-31 00:59:47 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-10-31 00:59:47 +0000 |
commit | af146490bb04205107cb23e301ec7a8ff927b5fc (patch) | |
tree | 13beeaed3698c61903fe93fb1ce70bd9b18d4e7f /libgo/go/net/dnsconfig_unix_test.go | |
parent | 725e1be3406315d9bcc8195d7eef0a7082b3c7cc (diff) |
runtime: Remove now unnecessary pad field from ParFor.
It is not needed due to the removal of the ctx field.
Reviewed-on: https://go-review.googlesource.com/16525
From-SVN: r229616
Diffstat (limited to 'libgo/go/net/dnsconfig_unix_test.go')
-rw-r--r-- | libgo/go/net/dnsconfig_unix_test.go | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/libgo/go/net/dnsconfig_unix_test.go b/libgo/go/net/dnsconfig_unix_test.go index 94fb0c32e24..c8eed618904 100644 --- a/libgo/go/net/dnsconfig_unix_test.go +++ b/libgo/go/net/dnsconfig_unix_test.go @@ -7,28 +7,30 @@ package net import ( + "os" "reflect" "testing" ) var dnsReadConfigTests = []struct { name string - conf dnsConfig + want *dnsConfig }{ { name: "testdata/resolv.conf", - conf: dnsConfig{ - servers: []string{"8.8.8.8", "2001:4860:4860::8888", "fe80::1%lo0"}, - search: []string{"localdomain"}, - ndots: 5, - timeout: 10, - attempts: 3, - rotate: true, + want: &dnsConfig{ + servers: []string{"8.8.8.8", "2001:4860:4860::8888", "fe80::1%lo0"}, + search: []string{"localdomain"}, + ndots: 5, + timeout: 10, + attempts: 3, + rotate: true, + unknownOpt: true, // the "options attempts 3" line }, }, { name: "testdata/domain-resolv.conf", - conf: dnsConfig{ + want: &dnsConfig{ servers: []string{"8.8.8.8"}, search: []string{"localdomain"}, ndots: 1, @@ -38,7 +40,7 @@ var dnsReadConfigTests = []struct { }, { name: "testdata/search-resolv.conf", - conf: dnsConfig{ + want: &dnsConfig{ servers: []string{"8.8.8.8"}, search: []string{"test", "invalid"}, ndots: 1, @@ -48,22 +50,51 @@ var dnsReadConfigTests = []struct { }, { name: "testdata/empty-resolv.conf", - conf: dnsConfig{ + want: &dnsConfig{ + servers: defaultNS, + ndots: 1, + timeout: 5, + attempts: 2, + }, + }, + { + name: "testdata/openbsd-resolv.conf", + want: &dnsConfig{ ndots: 1, timeout: 5, attempts: 2, + lookup: []string{"file", "bind"}, + servers: []string{"169.254.169.254", "10.240.0.1"}, + search: []string{"c.symbolic-datum-552.internal."}, }, }, } func TestDNSReadConfig(t *testing.T) { for _, tt := range dnsReadConfigTests { - conf, err := dnsReadConfig(tt.name) - if err != nil { - t.Fatal(err) + conf := dnsReadConfig(tt.name) + if conf.err != nil { + t.Fatal(conf.err) } - if !reflect.DeepEqual(conf, &tt.conf) { - t.Errorf("got %v; want %v", conf, &tt.conf) + if !reflect.DeepEqual(conf, tt.want) { + t.Errorf("%s:\ngot: %+v\nwant: %+v", tt.name, conf, tt.want) } } } + +func TestDNSReadMissingFile(t *testing.T) { + conf := dnsReadConfig("a-nonexistent-file") + if !os.IsNotExist(conf.err) { + t.Errorf("missing resolv.conf:\ngot: %v\nwant: %v", conf.err, os.ErrNotExist) + } + conf.err = nil + want := &dnsConfig{ + servers: defaultNS, + ndots: 1, + timeout: 5, + attempts: 2, + } + if !reflect.DeepEqual(conf, want) { + t.Errorf("missing resolv.conf:\ngot: %+v\nwant: %+v", conf, want) + } +} |