gatewaytest

package
v1.2.3-fred.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockUntilGatewayAcceptsConnections

func BlockUntilGatewayAcceptsConnections(t *testing.T, address string)

BlockUntilGatewayAcceptsConnections attempts to initiate a connection to the gateway on the given address. It will time out if that address doesn't respond in time.

Types

type MockListener

type MockListener struct {
	CloseCallCount int
	// contains filtered or unexported fields
}

MockListener forwards almost all calls to the real listener. When asked about address, it will return the one pointing at the fake port.

This lets us make calls to set the gateway port to a specific port without actually occupying those ports on the real system (which would lead to flaky tests otherwise).

func (*MockListener) Accept

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

func (*MockListener) Addr

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

func (*MockListener) Close

func (m *MockListener) Close() error

func (*MockListener) RealAddr

func (m *MockListener) RealAddr() net.Addr

type MockTCPPortAllocator

type MockTCPPortAllocator struct {
	PortsInUse []string

	CallCount int
	// contains filtered or unexported fields
}

func (*MockTCPPortAllocator) Listen

func (m *MockTCPPortAllocator) Listen(localAddress, localPort string) (net.Listener, error)

Listen accepts localPort as an argument but creates a listener on a random port. This lets us test code that attempt to set the port number to a specific value without risking that the actual port on the device running the tests is occupied.

Listen returns a mock listener which forwards all methods to the real listener on the random port but its Addr function returns the port that was given as an argument to Listen.

func (*MockTCPPortAllocator) RecentListener

func (m *MockTCPPortAllocator) RecentListener() *MockListener

Jump to

Keyboard shortcuts

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