ooni-probe-cli/internal/netxlite/mocks/dialer.go
Simone Basso 7a9499fee3
refactor(dialer): it should close idle connections (#457)
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
2021-09-05 19:55:28 +02:00

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()
}