testutils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 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 []servers.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 SendBrowserRequest

func SendBrowserRequest(
	service *browsing.Service,
	filters string,
	getAddrFunc func() (net.IP, int),
) ([]byte, error)

func SendHeartbeat

func SendHeartbeat(
	service *reporting.Service,
	instanceID []byte,
	getParamsFunc func() map[string]string,
	getAddrFunc func() (net.IP, int),
) ([]byte, error)

func StandardAddr

func StandardAddr() (net.IP, int)

func UnpackServerList

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

func WithBrowserChallengeLength

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

func WithCustomAddr

func WithCustomAddr(ip string, port int) func() (net.IP, int)

func WithExtraServerParams

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

func WithRandomAddr

func WithRandomAddr() func() (net.IP, int)

func WithServerParams

func WithServerParams(params map[string]string) func() map[string]string

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 TestRequestOpt

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

func MustBindJSON

func MustBindJSON(v interface{}) TestRequestOpt

func MustHaveNoBody

func MustHaveNoBody() TestRequestOpt

Jump to

Keyboard shortcuts

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