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 FSWatcher ¶ added in v0.107.0
type FSWatcher struct { OnEvents func() (e <-chan struct{}) OnAdd func(name string) (err error) OnClose func() (err error) }
FSWatcher is a mock aghos.FSWatcher implementation to use in tests.
func (*FSWatcher) Add ¶ added in v0.107.0
Add implements the aghos.FSWatcher interface for *FSWatcher.
type GlobFS ¶ added in v0.107.0
type GlobFS struct { // FS is embedded here to avoid implementing all it's methods. FS OnGlob func(pattern string) ([]string, error) }
GlobFS is a mock fs.GlobFS implementation to use in tests.
type StatFS ¶ added in v0.107.0
type StatFS struct { // FS is embedded here to avoid implementing all it's methods. FS OnStat func(name string) (fs.FileInfo, error) }
StatFS is a mock fs.StatFS implementation to use in tests.
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 unwrapped 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 Upstream ¶ added in v0.107.7
type Upstream struct { // 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 // Addr is the address for Address method. Addr string }
Upstream is a mock implementation of upstream.Upstream.