coredns/plugin/pkg/edns/edns_test.go
Miek Gieben d8714e64e4 Remove the word middleware (#1067)
* Rename middleware to plugin

first pass; mostly used 'sed', few spots where I manually changed
text.

This still builds a coredns binary.

* fmt error

* Rename AddMiddleware to AddPlugin

* Readd AddMiddleware to remain backwards compat
2017-09-14 09:36:06 +01:00

37 lines
607 B
Go

package edns
import (
"testing"
"github.com/miekg/dns"
)
func TestVersion(t *testing.T) {
m := ednsMsg()
m.Extra[0].(*dns.OPT).SetVersion(2)
_, err := Version(m)
if err == nil {
t.Errorf("expected wrong version, but got OK")
}
}
func TestVersionNoEdns(t *testing.T) {
m := ednsMsg()
m.Extra = nil
_, err := Version(m)
if err != nil {
t.Errorf("expected no error, but got one: %s", err)
}
}
func ednsMsg() *dns.Msg {
m := new(dns.Msg)
m.SetQuestion("example.com.", dns.TypeA)
o := new(dns.OPT)
o.Hdr.Name = "."
o.Hdr.Rrtype = dns.TypeOPT
m.Extra = append(m.Extra, o)
return m
}