diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-08-17 17:19:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-17 17:19:06 -0700 |
commit | 96eab1202717e073782ec399a4e0820cae15b1bb (patch) | |
tree | 011012982be971c7e9ef91466f026bc0956ac9a2 /vendor/github.com/miekg/dns/scan_test.go | |
parent | 2c895ee66eed626721135acfcc48254c6e3f3b29 (diff) | |
download | chat-96eab1202717e073782ec399a4e0820cae15b1bb.tar.gz chat-96eab1202717e073782ec399a4e0820cae15b1bb.tar.bz2 chat-96eab1202717e073782ec399a4e0820cae15b1bb.zip |
Updating server dependancies. (#7246)
Diffstat (limited to 'vendor/github.com/miekg/dns/scan_test.go')
-rw-r--r-- | vendor/github.com/miekg/dns/scan_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/github.com/miekg/dns/scan_test.go b/vendor/github.com/miekg/dns/scan_test.go new file mode 100644 index 000000000..b31c4c779 --- /dev/null +++ b/vendor/github.com/miekg/dns/scan_test.go @@ -0,0 +1,45 @@ +package dns + +import ( + "io/ioutil" + "os" + "strings" + "testing" +) + +func TestParseZoneInclude(t *testing.T) { + + tmpfile, err := ioutil.TempFile("", "dns") + if err != nil { + t.Fatalf("could not create tmpfile for test: %s", err) + } + + if _, err := tmpfile.WriteString("foo\tIN\tA\t127.0.0.1"); err != nil { + t.Fatalf("unable to write content to tmpfile %q: %s", tmpfile.Name(), err) + } + if err := tmpfile.Close(); err != nil { + t.Fatalf("could not close tmpfile %q: %s", tmpfile.Name(), err) + } + + zone := "$INCLUDE " + tmpfile.Name() + + tok := ParseZone(strings.NewReader(zone), "", "") + for x := range tok { + if x.Error != nil { + t.Fatalf("expected no error, but got %s", x.Error) + } + } + + os.Remove(tmpfile.Name()) + + tok = ParseZone(strings.NewReader(zone), "", "") + for x := range tok { + if x.Error == nil { + t.Fatalf("expected first token to contain an error but it didn't") + } + if !strings.Contains(x.Error.Error(), "failed to open") || + !strings.Contains(x.Error.Error(), tmpfile.Name()) { + t.Fatalf(`expected error to contain: "failed to open" and %q but got: %s`, tmpfile.Name(), x.Error) + } + } +} |