diff options
Diffstat (limited to 'middleware/pkg/storage/fs_test.go')
-rw-r--r-- | middleware/pkg/storage/fs_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/middleware/pkg/storage/fs_test.go b/middleware/pkg/storage/fs_test.go new file mode 100644 index 000000000..f7e8ccf9d --- /dev/null +++ b/middleware/pkg/storage/fs_test.go @@ -0,0 +1,42 @@ +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) + } + } +} |