2021-09-05 14:49:38 +02:00
|
|
|
package mocks
|
2021-06-23 16:21:13 +02:00
|
|
|
|
2021-09-27 23:09:41 +02:00
|
|
|
import (
|
|
|
|
"context"
|
2022-05-16 10:46:53 +02:00
|
|
|
"net"
|
2022-01-03 13:53:23 +01:00
|
|
|
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
2021-09-27 23:09:41 +02:00
|
|
|
)
|
2021-06-23 16:21:13 +02:00
|
|
|
|
|
|
|
// 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()
|
2022-01-03 13:53:23 +01:00
|
|
|
MockLookupHTTPS func(ctx context.Context, domain string) (*model.HTTPSSvc, error)
|
2022-05-16 10:46:53 +02:00
|
|
|
MockLookupNS func(ctx context.Context, domain string) ([]*net.NS, error)
|
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()
|
|
|
|
}
|
2021-09-27 23:09:41 +02:00
|
|
|
|
|
|
|
// LookupHTTPS calls MockLookupHTTPS.
|
2022-01-03 13:53:23 +01:00
|
|
|
func (r *Resolver) LookupHTTPS(ctx context.Context, domain string) (*model.HTTPSSvc, error) {
|
2021-09-27 23:09:41 +02:00
|
|
|
return r.MockLookupHTTPS(ctx, domain)
|
|
|
|
}
|
2022-05-16 10:46:53 +02:00
|
|
|
|
|
|
|
// LookupNS calls MockLookupNS.
|
|
|
|
func (r *Resolver) LookupNS(ctx context.Context, domain string) ([]*net.NS, error) {
|
|
|
|
return r.MockLookupNS(ctx, domain)
|
|
|
|
}
|