mirror of
https://github.com/coredns/coredns.git
synced 2025-11-02 02:03:13 -05:00
Cleanups and tests (#272)
For some reasons there was a dnsserver/middleware.go that defined the middleware handlers. This code was a repeat from middleware/middleware.go. Removed dnsserver/middleware.go and replaced all uses of dnsserver.Middleware with middleware.Middleware. Added dnsserver/address_test.go to test the zone normalization (and to improve the test coverage). The deleted file will also improve the test coverage :)
This commit is contained in:
28
core/dnsserver/address_test.go
Normal file
28
core/dnsserver/address_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package dnsserver
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNormalizeZone(t *testing.T) {
|
||||
for i, test := range []struct {
|
||||
input string
|
||||
expected string
|
||||
shouldErr bool
|
||||
}{
|
||||
{".", ".:53", false},
|
||||
{".:54", ".:54", false},
|
||||
{"..", ":", true},
|
||||
{"..", ":", true},
|
||||
} {
|
||||
addr, err := normalizeZone(test.input)
|
||||
actual := addr.String()
|
||||
if test.shouldErr && err == nil {
|
||||
t.Errorf("Test %d: Expected error, but there wasn't any", i)
|
||||
}
|
||||
if !test.shouldErr && err != nil {
|
||||
t.Errorf("Test %d: Expected no error, but there was one: %v", i, err)
|
||||
}
|
||||
if actual != test.expected {
|
||||
t.Errorf("Test %d: Expected %s but got %s", i, test.expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user