From d05369e62919c0bf5613fc988d310a1b338a3db3 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Mon, 6 Oct 2014 07:45:31 +0100 Subject: [PATCH] tests: remove parse_test.db Make it an string inside the test file and use strings.NewReader. --- parse_test.db | 6 ------ parse_test.go | 17 ++++++++++------- privaterr_test.go | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 parse_test.db diff --git a/parse_test.db b/parse_test.db deleted file mode 100644 index edbf87c5..00000000 --- a/parse_test.db +++ /dev/null @@ -1,6 +0,0 @@ -a.example.com. IN A 127.0.0.1 -8db7._openpgpkey.example.com. IN OPENPGPKEY mQCNAzIG -$ORIGIN a.example.com. -test IN A 127.0.0.1 -$ORIGIN b.example.com. -test IN CNAME test.a.example.com. diff --git a/parse_test.go b/parse_test.go index 346c9cc6..3c18b38d 100644 --- a/parse_test.go +++ b/parse_test.go @@ -7,7 +7,6 @@ import ( "fmt" "math/rand" "net" - "os" "reflect" "strconv" "strings" @@ -563,13 +562,17 @@ func TestParseFailure(t *testing.T) { } func TestZoneParsing(t *testing.T) { - f, err := os.Open("parse_test.db") - if err != nil { - return - } - defer f.Close() + // parse_test.db + db := ` +a.example.com. IN A 127.0.0.1 +8db7._openpgpkey.example.com. IN OPENPGPKEY mQCNAzIG +$ORIGIN a.example.com. +test IN A 127.0.0.1 +$ORIGIN b.example.com. +test IN CNAME test.a.example.com. +` start := time.Now().UnixNano() - to := ParseZone(f, "", "parse_test.db") + to := ParseZone(strings.NewReader(db), "", "parse_test.db") var i int for x := range to { i++ diff --git a/privaterr_test.go b/privaterr_test.go index 83cd8465..6f1dff89 100644 --- a/privaterr_test.go +++ b/privaterr_test.go @@ -15,7 +15,7 @@ type ISBN struct { func NewISBN() dns.PrivateRdata { return &ISBN{""} } -func (rd *ISBN) Len() int { return len([]byte(rd.x)) } +func (rd *ISBN) Len() int { return len([]byte(rd.x)) } func (rd *ISBN) String() string { return rd.x } func (rd *ISBN) Parse(txt []string) error {