Move all (almost all) Go files in middleware into their own packages. This makes for better naming and discoverability. Lot of changes elsewhere to make this change. The middleware.State was renamed to request.Request which is better, but still does not cover all use-cases. It was also moved out middleware because it is used by `dnsserver` as well. A pkg/dnsutil packages was added for shared, handy, dns util functions. All normalize functions are now put in normalize.go
42 lines
967 B
Go
42 lines
967 B
Go
package storage
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestfsPath(t *testing.T) {
|
|
if actual := fsPath(); !strings.HasSuffix(actual, ".coredns") {
|
|
t.Errorf("Expected path to be a .coredns folder, got: %v", actual)
|
|
}
|
|
|
|
os.Setenv("COREDNSPATH", "testpath")
|
|
defer os.Setenv("COREDNSPATH", "")
|
|
if actual, expected := fsPath(), "testpath"; actual != expected {
|
|
t.Errorf("Expected path to be %v, got: %v", expected, actual)
|
|
}
|
|
}
|
|
|
|
func TestZone(t *testing.T) {
|
|
for _, ts := range []string{"example.org.", "example.org"} {
|
|
d := CoreDir.Zone(ts)
|
|
actual := path.Base(string(d))
|
|
expected := "D" + ts
|
|
if actual != expected {
|
|
t.Errorf("Expected path to be %v, got %v", actual, expected)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestZoneRoot(t *testing.T) {
|
|
for _, ts := range []string{"."} {
|
|
d := CoreDir.Zone(ts)
|
|
actual := path.Base(string(d))
|
|
expected := "D" + ts
|
|
if actual != expected {
|
|
t.Errorf("Expected path to be %v, got %v", actual, expected)
|
|
}
|
|
}
|
|
}
|