* Add a setup test for middleware/file

This fix adds a setup test for middleware/file so that there is
a basic coverage for the Corefile processing of middleware/file.

This fix is related to 308 (Will look into it).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* middleware/file: use helper function for test

Fixup setup_test.go and use the test.TempFile function to make things
somewhat shorter.

Use clean up the use of testing.T in TempFile - it is not used.
This commit is contained in:
Miek Gieben 2016-10-02 15:58:01 +01:00 committed by GitHub
parent e54c232c8c
commit 4096c4906d
12 changed files with 82 additions and 19 deletions

View file

@ -17,7 +17,7 @@ import (
func TestLookupCache(t *testing.T) {
// Start auth. CoreDNS holding the auth zone.
name, rm, err := test.TempFile(t, ".", exampleOrg)
name, rm, err := test.TempFile(".", exampleOrg)
if err != nil {
t.Fatalf("failed to created zone: %s", err)
}

View file

@ -3,11 +3,10 @@ package test
import (
"io/ioutil"
"os"
"testing"
)
// TempFile will create a temporary file on disk and returns the name and a cleanup function to remove it later.
func TempFile(t *testing.T, dir, content string) (string, func(), error) {
func TempFile(dir, content string) (string, func(), error) {
f, err := ioutil.TempFile(dir, "go-test-tmpfile")
if err != nil {
return "", nil, err

View file

@ -3,7 +3,7 @@ package test
import "testing"
func TestTempFile(t *testing.T) {
_, f, e := TempFile(t, ".", "test")
_, f, e := TempFile(".", "test")
if e != nil {
t.Fatalf("failed to create temp file: %s", e)
}

View file

@ -12,7 +12,7 @@ import (
)
func TestLookupBalanceRewriteCacheDnssec(t *testing.T) {
name, rm, err := test.TempFile(t, ".", exampleOrg)
name, rm, err := test.TempFile(".", exampleOrg)
if err != nil {
t.Fatalf("failed to created zone: %s", err)
}

View file

@ -12,7 +12,7 @@ import (
func benchmarkLookupBalanceRewriteCache(b *testing.B) {
t := new(testing.T)
name, rm, err := test.TempFile(t, ".", exampleOrg)
name, rm, err := test.TempFile(".", exampleOrg)
if err != nil {
t.Fatalf("failed to created zone: %s", err)
}

View file

@ -21,7 +21,7 @@ example.org. IN A 127.0.0.2
`
func TestLookupProxy(t *testing.T) {
name, rm, err := test.TempFile(t, ".", exampleOrg)
name, rm, err := test.TempFile(".", exampleOrg)
if err != nil {
t.Fatalf("failed to created zone: %s", err)
}