testutils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertServers added in v0.3.0

func AssertServers(t testing.TB, expected []string, actual []server.Server)

func CalcReqLength

func CalcReqLength(req []byte) int

func GenBrowserChallenge

func GenBrowserChallenge(l uint) []byte

func GenBrowserChallenge8

func GenBrowserChallenge8() []byte

func GenExtraServerParams

func GenExtraServerParams(extra map[string]string) map[string]string

func GenRandomIP

func GenRandomIP() net.IP

func GenServerParams

func GenServerParams() map[string]string

func PackBrowserRequest

func PackBrowserRequest(
	fields []string,
	filters string,
	options []byte,
	getChallenge func() []byte,
	getLengthFunc func([]byte) int,
) []byte

func PackHeartbeatRequest

func PackHeartbeatRequest(instanceID []byte, params map[string]string) []byte

func PrepareTestServer

func PrepareTestServer(tb fxtest.TB, extra ...fx.Option) (*httptest.Server, func())

func PrepareTestServerWithRepos added in v0.7.0

func PrepareTestServerWithRepos(
	tb fxtest.TB,
	extra ...fx.Option,
) (*httptest.Server, persistence.Repositories, func())

func SendBrowserRequest

func SendBrowserRequest(address string, filters string) []byte

func SendTCP added in v0.7.0

func SendTCP(address string, req []byte) []byte

func SendUDP added in v0.7.0

func SendUDP(address string, req []byte) []byte

func UnpackServerList

func UnpackServerList(resp []byte) []map[string]string

func WithBrowserChallengeLength

func WithBrowserChallengeLength(l int) func([]byte) int

Types

type Response

type Response struct {
	StatusCode int
	Body       string
}

func DoTestRequest

func DoTestRequest(
	ts *httptest.Server, method, path string, body io.Reader, opts ...TestRequestOpt,
) Response

type TCPClient added in v0.7.0

type TCPClient struct {
	// contains filtered or unexported fields
}

func NewTCPClient added in v0.7.0

func NewTCPClient(address string, bufSize int, readTimeout time.Duration) *TCPClient

func (*TCPClient) Close added in v0.7.0

func (c *TCPClient) Close()

func (*TCPClient) Send added in v0.7.0

func (c *TCPClient) Send(req []byte) ([]byte, error)

type TestRequestOpt

type TestRequestOpt func(*http.Request, *http.Response)

func MustBindJSON

func MustBindJSON(v interface{}) TestRequestOpt

func MustHaveNoBody

func MustHaveNoBody() TestRequestOpt

type UDPClient added in v0.7.0

type UDPClient struct {
	LocalAddr *net.UDPAddr
	// contains filtered or unexported fields
}

func NewUDPClient added in v0.7.0

func NewUDPClient(address string, bufSize int, readTimeout time.Duration) *UDPClient

func (*UDPClient) Close added in v0.7.0

func (c *UDPClient) Close()

func (*UDPClient) Send added in v0.7.0

func (c *UDPClient) Send(req []byte) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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