* Make CoreDNS a server type plugin for Caddy Remove code we don't need and port all middleware over. Fix all tests and rework the documentation. Also make `go generate` build a caddy binary which we then copy into our directory. This means `go build`-builds remain working as-is. And new etc instances in each etcd test for better isolation. Fix more tests and rework test.Server with the newer support Caddy offers. Fix Makefile to support new mode of operation.
20 lines
511 B
Go
20 lines
511 B
Go
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) {
|
|
f, err := ioutil.TempFile(dir, "go-test-tmpfile")
|
|
if err != nil {
|
|
return "", nil, err
|
|
}
|
|
if err := ioutil.WriteFile(f.Name(), []byte(content), 0644); err != nil {
|
|
return "", nil, err
|
|
}
|
|
rmFunc := func() { os.Remove(f.Name()) }
|
|
return f.Name(), rmFunc, nil
|
|
}
|