diff options
author | 2017-09-26 17:45:33 +0200 | |
---|---|---|
committer | 2017-09-26 11:45:33 -0400 | |
commit | daf8ef0da8a9aafc610f7a3dbcf021ec4365ee72 (patch) | |
tree | b56cacdd1ef11c68757b8e320894b88f1e4500a4 /plugin/dnstap/handler_test.go | |
parent | 2a32cd415911bea79784bee3387103bd9576f438 (diff) | |
download | coredns-daf8ef0da8a9aafc610f7a3dbcf021ec4365ee72.tar.gz coredns-daf8ef0da8a9aafc610f7a3dbcf021ec4365ee72.tar.zst coredns-daf8ef0da8a9aafc610f7a3dbcf021ec4365ee72.zip |
Adds the dnstap I/O routines and should fix some issues (#1083)
* adds the dnstap I/O thread and should fix a lot of mistakes
* docs
* -race test
* oops
* docs
Diffstat (limited to 'plugin/dnstap/handler_test.go')
-rw-r--r-- | plugin/dnstap/handler_test.go | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/plugin/dnstap/handler_test.go b/plugin/dnstap/handler_test.go index 54509de82..617c8e675 100644 --- a/plugin/dnstap/handler_test.go +++ b/plugin/dnstap/handler_test.go @@ -1,21 +1,18 @@ package dnstap import ( - "errors" - "fmt" "testing" "github.com/coredns/coredns/plugin/dnstap/test" mwtest "github.com/coredns/coredns/plugin/test" tap "github.com/dnstap/golang-dnstap" - "github.com/golang/protobuf/proto" "github.com/miekg/dns" "golang.org/x/net/context" ) func testCase(t *testing.T, tapq, tapr *tap.Message, q, r *dns.Msg) { - w := writer{} + w := writer{t: t} w.queue = append(w.queue, tapq, tapr) h := Dnstap{ Next: mwtest.HandlerFunc(func(_ context.Context, @@ -23,7 +20,7 @@ func testCase(t *testing.T, tapq, tapr *tap.Message, q, r *dns.Msg) { return 0, w.WriteMsg(r) }), - Out: &w, + IO: &w, Pack: false, } _, err := h.ServeDNS(context.TODO(), &mwtest.ResponseWriter{}, q) @@ -33,22 +30,18 @@ func testCase(t *testing.T, tapq, tapr *tap.Message, q, r *dns.Msg) { } type writer struct { + t *testing.T queue []*tap.Message } -func (w *writer) Write(b []byte) (int, error) { - e := tap.Dnstap{} - if err := proto.Unmarshal(b, &e); err != nil { - return 0, err - } +func (w *writer) Dnstap(e tap.Dnstap) { if len(w.queue) == 0 { - return 0, errors.New("message not expected") + w.t.Error("Message not expected.") } if !test.MsgEqual(w.queue[0], e.Message) { - return 0, fmt.Errorf("want: %v, have: %v", w.queue[0], e.Message) + w.t.Errorf("want: %v, have: %v", w.queue[0], e.Message) } w.queue = w.queue[1:] - return len(b), nil } func TestDnstap(t *testing.T) { |