2021-09-05 14:49:38 +02:00
|
|
|
package mocks
|
2021-06-23 16:21:13 +02:00
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
// Resolver is a mockable Resolver.
|
|
|
|
type Resolver struct {
|
2021-09-05 18:03:50 +02:00
|
|
|
MockLookupHost func(ctx context.Context, domain string) ([]string, error)
|
|
|
|
MockNetwork func() string
|
|
|
|
MockAddress func() string
|
|
|
|
MockCloseIdleConnections func()
|
2021-06-23 16:21:13 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 17:00:44 +02:00
|
|
|
// LookupHost calls MockLookupHost.
|
2021-06-23 16:21:13 +02:00
|
|
|
func (r *Resolver) LookupHost(ctx context.Context, domain string) ([]string, error) {
|
|
|
|
return r.MockLookupHost(ctx, domain)
|
|
|
|
}
|
|
|
|
|
2021-06-23 17:00:44 +02:00
|
|
|
// Address calls MockAddress.
|
2021-06-23 16:21:13 +02:00
|
|
|
func (r *Resolver) Address() string {
|
|
|
|
return r.MockAddress()
|
|
|
|
}
|
|
|
|
|
2021-06-23 17:00:44 +02:00
|
|
|
// Network calls MockNetwork.
|
2021-06-23 16:21:13 +02:00
|
|
|
func (r *Resolver) Network() string {
|
|
|
|
return r.MockNetwork()
|
|
|
|
}
|
2021-09-05 18:03:50 +02:00
|
|
|
|
|
|
|
// CloseIdleConnections calls MockCloseIdleConnections.
|
|
|
|
func (r *Resolver) CloseIdleConnections() {
|
|
|
|
r.MockCloseIdleConnections()
|
|
|
|
}
|