2021-06-23 16:06:02 +02:00
|
|
|
package netxmocks
|
2021-06-08 23:59:30 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
|
|
|
// dialer is the interface we expect from a dialer
|
|
|
|
type dialer interface {
|
|
|
|
DialContext(ctx context.Context, network, address string) (net.Conn, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dialer is a mockable Dialer.
|
|
|
|
type Dialer struct {
|
|
|
|
MockDialContext func(ctx context.Context, network, address string) (net.Conn, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DialContext implements Dialer.DialContext.
|
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-06-23 16:21:13 +02:00
|
|
|
var _ dialer = &Dialer{}
|