coredns/middleware/pkg/edns/edns_test.go
Miek Gieben d1f17fa7e0 Cleanup: put middleware helper functions in pkgs (#245)
Move all (almost all) Go files in middleware into their
own packages. This makes for better naming and discoverability.

Lot of changes elsewhere to make this change.

The middleware.State was renamed to request.Request which is better,
but still does not cover all use-cases. It was also moved out middleware
because it is used by `dnsserver` as well.

A pkg/dnsutil packages was added for shared, handy, dns util functions.

All normalize functions are now put in normalize.go
2016-09-07 11:10:16 +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
}