mock

package
v2.0.437+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2018 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	NetworkString string
	AddrString    string
}

Addr is a fake network interface which implements the net.Addr interface

func (Addr) Network

func (a Addr) Network() string

Network gets the network string.

func (Addr) String

func (a Addr) String() string

Network gets the addr string.

type Conn

type Conn struct {
	Server *End
	Client *End
}

Conn facilitates testing by providing two connected ReadWriteClosers each of which can be used in place of a net.Conn

func NewConn

func NewConn() *Conn

NewConn creates a new mock connection.

func (*Conn) Close

func (c *Conn) Close() (err error)

Close closes the mock connection.

type End

type End struct {
	Reader *io.PipeReader
	Writer *io.PipeWriter
}

End is one 'end' of a simulated connection.

func (End) Close

func (e End) Close() (err error)

Close closes the End.

func (End) LocalAddr

func (e End) LocalAddr() net.Addr

LocalAddr gets the local address.

func (End) Read

func (e End) Read(data []byte) (n int, err error)

Read implements the interface.

func (End) RemoteAddr

func (e End) RemoteAddr() net.Addr

RemoteAddr gets the local address.

func (End) SetDeadline

func (e End) SetDeadline(t time.Time) error

SetDeadline implements the interface.

func (End) SetReadDeadline

func (e End) SetReadDeadline(t time.Time) error

SetReadDeadline implements the interface.

func (End) SetWriteDeadline

func (e End) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements the interface.

func (End) Write

func (e End) Write(data []byte) (n int, err error)

Write implements the interface.

type Noop

type Noop struct{}

Noop is a fake connection.

func NewNoop

func NewNoop() *Noop

NewNoop returns a new noop.

func (Noop) Close

func (e Noop) Close() (err error)

Close closes the End.

func (Noop) LocalAddr

func (e Noop) LocalAddr() net.Addr

LocalAddr gets the local address.

func (Noop) Read

func (e Noop) Read(data []byte) (n int, err error)

Read implements the interface.

func (Noop) RemoteAddr

func (e Noop) RemoteAddr() net.Addr

RemoteAddr gets the local address.

func (Noop) SetDeadline

func (e Noop) SetDeadline(t time.Time) error

SetDeadline implements the interface.

func (Noop) SetReadDeadline

func (e Noop) SetReadDeadline(t time.Time) error

SetReadDeadline implements the interface.

func (Noop) SetWriteDeadline

func (e Noop) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements the interface.

func (Noop) Write

func (e Noop) Write(data []byte) (n int, err error)

Write implements the interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL