aboutsummaryrefslogtreecommitdiff
path: root/plugin/pkg/dnstest/server_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/pkg/dnstest/server_test.go')
-rw-r--r--plugin/pkg/dnstest/server_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/plugin/pkg/dnstest/server_test.go b/plugin/pkg/dnstest/server_test.go
new file mode 100644
index 000000000..3f23c340b
--- /dev/null
+++ b/plugin/pkg/dnstest/server_test.go
@@ -0,0 +1,28 @@
+package dnstest
+
+import (
+ "testing"
+
+ "github.com/miekg/dns"
+)
+
+func TestNewServer(t *testing.T) {
+ s := NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
+ ret := new(dns.Msg)
+ ret.SetReply(r)
+ w.WriteMsg(ret)
+ })
+ defer s.Close()
+
+ c := new(dns.Client)
+ c.Net = "tcp"
+ m := new(dns.Msg)
+ m.SetQuestion("example.org.", dns.TypeSOA)
+ ret, _, err := c.Exchange(m, s.Addr)
+ if err != nil {
+ t.Fatalf("Could not send message to dnstest.Server: %s", err)
+ }
+ if ret.Id != m.Id {
+ t.Fatalf("Msg ID's should match, expected %d, got %d", m.Id, ret.Id)
+ }
+}