2021-09-05 14:49:38 +02:00
|
|
|
package mocks
|
2021-06-08 23:59:30 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Dialer is a mockable Dialer.
|
|
|
|
type Dialer struct {
|
2021-09-05 19:55:28 +02:00
|
|
|
MockDialContext func(ctx context.Context, network, address string) (net.Conn, error)
|
|
|
|
MockCloseIdleConnections func()
|
2021-06-08 23:59:30 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 17:00:44 +02:00
|
|
|
// DialContext calls MockDialContext.
|
2021-06-23 16:21:13 +02:00
|
|
|
func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
2021-06-08 23:59:30 +02:00
|
|
|
return d.MockDialContext(ctx, network, address)
|
|
|
|
}
|
2021-09-05 19:55:28 +02:00
|
|
|
|
|
|
|
// CloseIdleConnections calls MockCloseIdleConnections.
|
|
|
|
func (d *Dialer) CloseIdleConnections() {
|
|
|
|
d.MockCloseIdleConnections()
|
|
|
|
}
|