mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 18:53:43 -04:00
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:
@@ -3,7 +3,7 @@ package metrics
|
||||
import (
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/metrics/vars"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnstest"
|
||||
"github.com/coredns/coredns/plugin/pkg/rcode"
|
||||
"github.com/coredns/coredns/request"
|
||||
|
||||
@@ -22,7 +22,7 @@ func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
|
||||
}
|
||||
|
||||
// Record response to get status code and size of the reply.
|
||||
rw := dnsrecorder.New(w)
|
||||
rw := dnstest.NewRecorder(w)
|
||||
status, err := plugin.NextOrFailure(m.Name(), m.Next, ctx, rw, r)
|
||||
|
||||
vars.Report(state, zone, rcode.ToString(rw.Rcode), rw.Len, rw.Start)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/coredns/coredns/plugin"
|
||||
mtest "github.com/coredns/coredns/plugin/metrics/test"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnsrecorder"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnstest"
|
||||
"github.com/coredns/coredns/plugin/test"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
@@ -65,7 +65,7 @@ func TestMetrics(t *testing.T) {
|
||||
req.SetQuestion(dns.Fqdn(tc.qname), tc.qtype)
|
||||
met.Next = tc.next
|
||||
|
||||
rec := dnsrecorder.New(&test.ResponseWriter{})
|
||||
rec := dnstest.NewRecorder(&test.ResponseWriter{})
|
||||
_, err := met.ServeDNS(ctx, rec, req)
|
||||
if err != nil {
|
||||
t.Fatalf("Test %d: Expected no error, but got %s", i, err)
|
||||
|
||||
Reference in New Issue
Block a user