7a9499fee3
Like we did before for the resolver, a dialer should propagate the request to close idle connections to underlying types. See https://github.com/ooni/probe/issues/1591
23 lines
544 B
Go
23 lines
544 B
Go
package mocks
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
)
|
|
|
|
// Dialer is a mockable Dialer.
|
|
type Dialer struct {
|
|
MockDialContext func(ctx context.Context, network, address string) (net.Conn, error)
|
|
MockCloseIdleConnections func()
|
|
}
|
|
|
|
// DialContext calls MockDialContext.
|
|
func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
|
return d.MockDialContext(ctx, network, address)
|
|
}
|
|
|
|
// CloseIdleConnections calls MockCloseIdleConnections.
|
|
func (d *Dialer) CloseIdleConnections() {
|
|
d.MockCloseIdleConnections()
|
|
}
|