taskcluster-worker: github.com/taskcluster/taskcluster-worker/engines/mock/mocknet Index | Files

package mocknet

import "github.com/taskcluster/taskcluster-worker/engines/mock/mocknet"

Package mocknet implements a net.Listener interface that can reached with mocknet.Dial() and establishes connections using net.Pipe()

This is useful for testing things that needs net.Listener and net.Conn instances without creating a TCP listener on localhost.


Package Files

addr.go doc.go errors.go listener.go


var ErrAddressInUse = errors.New("address is already in use by another listener")

ErrAddressInUse is returned if the address already is in use

var ErrConnRefused = errors.New("connection refused, no listener for the given address")

ErrConnRefused is returned if the connection is refused

var ErrListenerClosed = errors.New("listener has been closed")

ErrListenerClosed is returned when a listener has been closed

func Dial Uses

func Dial(addr string) (net.Conn, error)

Dial creates a new connection to mock network identified by addr

type MockAddr Uses

type MockAddr struct {
    // contains filtered or unexported fields

MockAddr is an net.Addr implementation for MockListener

func (*MockAddr) Network Uses

func (a *MockAddr) Network() string

Network returns a network type identifier, like net.Addr.Network()

func (*MockAddr) String Uses

func (a *MockAddr) String() string

String returns address on string form, like net.Addr.String()

type MockListener Uses

type MockListener struct {
    // contains filtered or unexported fields

MockListener is implementation of net.Listener that allowd for establishment of net.Pipe() connections pairs

func Listen Uses

func Listen(addr string) (*MockListener, error)

Listen for new mock connections to addr

func (*MockListener) Accept Uses

func (l *MockListener) Accept() (net.Conn, error)

Accept new connections, see net.Listener.Accept()

func (*MockListener) Addr Uses

func (l *MockListener) Addr() net.Addr

Addr returns the listener's network address.

func (*MockListener) Close Uses

func (l *MockListener) Close() error

Close closes the listener.

Package mocknet imports 4 packages (graph) and is imported by 1 packages. Updated 2017-03-04. Refresh now. Tools for package owners.