testutil

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

testutil is a package that implements a set of functions for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectTCPServer

func ConnectTCPServer(address string) (net.Conn, error)

func FreeLocalAddress

func FreeLocalAddress() string

FreeLocalAddress returns free local address. -> 127.0.0.1:<free port>

func FreePort

func FreePort() uint16

FreePort returns free port.

func StartTCPServer

func StartTCPServer(ctx context.Context, handler func(net.Conn)) (net.Listener, error)

StartTCPServer start tcp server.

Types

type MockConn

type MockConn struct {
	ChReadArgs     chan []byte
	MockRead       func(b []byte) (n int, err error)
	ChWriteArgs    chan []byte
	MockWrite      func(b []byte) (n int, err error)
	MockClose      func() error
	MockLocalAddr  func() net.Addr
	MockRemoteAddr func() net.Addr
}

func NewMockConn

func NewMockConn() *MockConn

func (*MockConn) Close

func (mock *MockConn) Close() error

func (*MockConn) LocalAddr

func (mock *MockConn) LocalAddr() net.Addr

func (*MockConn) Read

func (mock *MockConn) Read(b []byte) (n int, err error)

func (*MockConn) RemoteAddr

func (mock *MockConn) RemoteAddr() net.Addr

func (*MockConn) SetDeadline

func (mock *MockConn) SetDeadline(t time.Time) error

func (*MockConn) SetReadDeadline

func (mock *MockConn) SetReadDeadline(t time.Time) error

func (*MockConn) SetWriteDeadline

func (mock *MockConn) SetWriteDeadline(t time.Time) error

func (*MockConn) Write

func (mock *MockConn) Write(b []byte) (n int, err error)

type MockListener

type MockListener struct {
	MockAccept func() (net.Conn, error)
	MockClose  func() error
	MockAddr   func() net.Addr
}

func NewMockListener

func NewMockListener() *MockListener

func (*MockListener) Accept

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

func (*MockListener) Addr

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

func (*MockListener) Close

func (mock *MockListener) Close() error

type ReadMessageResult

type ReadMessageResult struct {
	MessageType int
	Message     []byte
	Err         error
}

func (*ReadMessageResult) UnmarshalMessage

func (result *ReadMessageResult) UnmarshalMessage() (*aws.Message, error)

type SecureTunnelServer

type SecureTunnelServer struct {
	Host           string
	Endpoint       *url.URL
	ChRequest      chan *http.Request
	ChMessage      chan *ReadMessageResult
	ChWebSocket    chan *websocket.Conn
	ChPing         chan string
	RequestHandler func(w http.ResponseWriter, r *http.Request) (endResponse bool)
}

func NewSecureTunnelServer

func NewSecureTunnelServer() *SecureTunnelServer

func (*SecureTunnelServer) Start

func (server *SecureTunnelServer) Start(ctx context.Context)

Jump to

Keyboard shortcuts

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