pkg: add dnstest (#1098)

Add a full test server impl in this new package + tests. Move
dnsrecorder into this package as well and finish up the commented out
tests that were left in the old dnsrecorder package.

Update all callers and tests.
This commit is contained in:
Miek Gieben
2017-09-21 15:15:47 +01:00
committed by GitHub
parent 7109c6715c
commit 284061eee7
44 changed files with 223 additions and 131 deletions

View File

@@ -8,7 +8,7 @@ import (
"testing"
"github.com/coredns/coredns/plugin/etcd/msg"
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test"
"github.com/miekg/dns"
@@ -25,7 +25,7 @@ func TestCnameLookup(t *testing.T) {
for _, tc := range dnsTestCasesCname {
m := tc.Msg()
rec := dnsrecorder.New(&test.ResponseWriter{})
rec := dnstest.NewRecorder(&test.ResponseWriter{})
_, err := etc.ServeDNS(ctxt, rec, m)
if err != nil {
t.Errorf("expected no error, got %v\n", err)

View File

@@ -6,7 +6,7 @@ import (
"testing"
"github.com/coredns/coredns/plugin/etcd/msg"
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test"
"github.com/miekg/dns"
@@ -22,7 +22,7 @@ func TestGroupLookup(t *testing.T) {
for _, tc := range dnsTestCasesGroup {
m := tc.Msg()
rec := dnsrecorder.New(&test.ResponseWriter{})
rec := dnstest.NewRecorder(&test.ResponseWriter{})
_, err := etc.ServeDNS(ctxt, rec, m)
if err != nil {
t.Errorf("expected no error, got %v\n", err)

View File

@@ -9,7 +9,7 @@ import (
"time"
"github.com/coredns/coredns/plugin/etcd/msg"
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/pkg/singleflight"
"github.com/coredns/coredns/plugin/pkg/tls"
"github.com/coredns/coredns/plugin/proxy"
@@ -262,7 +262,7 @@ func TestLookup(t *testing.T) {
for _, tc := range dnsTestCases {
m := tc.Msg()
rec := dnsrecorder.New(&test.ResponseWriter{})
rec := dnstest.NewRecorder(&test.ResponseWriter{})
etc.ServeDNS(ctxt, rec, m)
resp := rec.Msg

View File

@@ -6,7 +6,7 @@ import (
"testing"
"github.com/coredns/coredns/plugin/etcd/msg"
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test"
"github.com/miekg/dns"
@@ -25,7 +25,7 @@ func TestMultiLookup(t *testing.T) {
for _, tc := range dnsTestCasesMulti {
m := tc.Msg()
rec := dnsrecorder.New(&test.ResponseWriter{})
rec := dnstest.NewRecorder(&test.ResponseWriter{})
_, err := etc.ServeDNS(ctxt, rec, m)
if err != nil {
t.Errorf("expected no error, got %v\n", err)

View File

@@ -10,7 +10,7 @@ import (
"testing"
"github.com/coredns/coredns/plugin/etcd/msg"
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test"
"github.com/miekg/dns"
@@ -26,7 +26,7 @@ func TestOtherLookup(t *testing.T) {
for _, tc := range dnsTestCasesOther {
m := tc.Msg()
rec := dnsrecorder.New(&test.ResponseWriter{})
rec := dnstest.NewRecorder(&test.ResponseWriter{})
_, err := etc.ServeDNS(ctxt, rec, m)
if err != nil {
t.Errorf("expected no error, got %v\n", err)

View File

@@ -8,7 +8,7 @@ import (
"testing"
"github.com/coredns/coredns/plugin/etcd/msg"
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test"
"github.com/miekg/dns"
@@ -51,7 +51,7 @@ func TestStubLookup(t *testing.T) {
for _, tc := range dnsTestCasesStub {
m := tc.Msg()
rec := dnsrecorder.New(&test.ResponseWriter{})
rec := dnstest.NewRecorder(&test.ResponseWriter{})
_, err := etc.ServeDNS(ctxt, rec, m)
if err != nil && m.Question[0].Name == "example.org." {
// This is OK, we expect this backend to *not* work.