Documentation ¶
Overview ¶
Package aghtest contains utilities for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscardLogOutput ¶
DiscardLogOutput runs tests with discarded logger output.
func ReplaceLogLevel ¶
ReplaceLogLevel sets logging level to l and uses Cleanup method of t to revert changes.
Types ¶
type TestBlockUpstream ¶
type TestBlockUpstream struct { Hostname string Block bool // contains filtered or unexported fields }
TestBlockUpstream implements upstream.Upstream interface for replacing real upstream in tests.
func (*TestBlockUpstream) Address ¶
func (u *TestBlockUpstream) Address() string
Address always returns an empty string.
func (*TestBlockUpstream) Exchange ¶
Exchange returns a message unique for TestBlockUpstream's Hostname-Block pair.
func (*TestBlockUpstream) RequestsCount ¶
func (u *TestBlockUpstream) RequestsCount() int
RequestsCount returns the number of handled requests. It's safe for concurrent use.
type TestErrUpstream ¶
type TestErrUpstream struct { // The error returned by Exchange may be unwraped to the Err. Err error }
TestErrUpstream implements upstream.Upstream interface for replacing real upstream in tests.
func (*TestErrUpstream) Address ¶
func (u *TestErrUpstream) Address() string
Address always returns an empty string.
type TestResolver ¶
type TestResolver struct {
// contains filtered or unexported fields
}
TestResolver is a Resolver for tests.
func (*TestResolver) Counter ¶
func (r *TestResolver) Counter() int
Counter returns the number of requests handled.
func (*TestResolver) HostToIPs ¶
func (r *TestResolver) HostToIPs(host string) (ipv4, ipv6 net.IP)
HostToIPs generates IPv4 and IPv6 from host.
func (*TestResolver) LookupHost ¶
func (r *TestResolver) LookupHost(host string) (addrs []string, err error)
LookupHost implements Resolver interface for *testResolver. It returns the slice of IPv4 and IPv6 instances converted to strings.
type TestUpstream ¶
type TestUpstream struct { // Addr is the address for Address method. Addr string // CName is a map of hostname to canonical name. CName map[string]string // IPv4 is a map of hostname to IPv4. IPv4 map[string][]net.IP // IPv6 is a map of hostname to IPv6. IPv6 map[string][]net.IP // Reverse is a map of address to domain name. Reverse map[string][]string }
TestUpstream is a mock of real upstream.
func (*TestUpstream) Address ¶
func (u *TestUpstream) Address() string
Address implements upstream.Upstream interface for *TestUpstream.