Documentation ¶
Index ¶
- type Conn
- func New(received *bytes.Buffer, responseReader io.Reader) *Conn
- func NewConn(received *bytes.Buffer, responseReader io.Reader, readError error, ...) *Conn
- func NewFailingOnRead(received *bytes.Buffer, responseReader io.Reader, readError error) *Conn
- func NewFailingOnWrite(received *bytes.Buffer, responseReader io.Reader, writeError error) *Conn
- func (c *Conn) Close() error
- func (c *Conn) Closed() bool
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (n int, err error)
- type Dialer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func NewConn ¶
func NewConn(received *bytes.Buffer, responseReader io.Reader, readError error, writeError error) *Conn
NewConn creates a new mock net.Conn.
func NewFailingOnRead ¶
NewFailingOnRead returns a connection that fails on read using a static error.
func NewFailingOnWrite ¶
NewFailingOnWrite returns a connection that fails on write using a static error.
func (*Conn) RemoteAddr ¶
type Dialer ¶
type Dialer interface { // Like net.Dial Dial(network, addr string) (net.Conn, error) // Like net.DialTimeout DialTimeout(network, addr string, timeout time.Duration) (net.Conn, error) // Like net.DialContext DialContext(ctx context.Context, network, addr string) (net.Conn, error) // Gets the last dialed address LastDialed() string // Gets all received data Received() []byte // Returns true if all dialed connections are closed AllClosed() bool }
Dialer is a test dialer that provides a net.Dial and net.DialTimeout equivalent backed by an in-memory data structure, and that provides access to the received data via the Received() method.
func AutoClose ¶
AutoClose wraps a dialer to close the connection automatically after writing response.
func FailingDialer ¶
FailingDialer constructs a new Dialer that fails to dial with the given error.
func SlowDialer ¶
SlowDialer wraps a dialer to add a delay when dialing it.
func SlowResponder ¶
SlowResponder wraps a dialer to add a delay when writing response to the dialed connection.
func SucceedingDialer ¶
SucceedingDialer constructs a new Dialer that responds with the given canned responseData.