test

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PaginatedEndpointTester

func PaginatedEndpointTester(
	t *testing.T,
	baseRequest RequestTester,
	pageQueryParamName string,
	maxPage int,
)

func TeardownGlobal

func TeardownGlobal(mainTestEnv *MainTestEnv) error

func TeardownSingle

func TeardownSingle(testEnv Env)

Types

type Env

type Env struct {
	TestTx  Tx
	TestCtx context.Context
}

func SetupSingle

func SetupSingle(mainTestEnv *MainTestEnv) Env

type ErrorMessage

type ErrorMessage = map[string]interface{}

type MainTestEnv

type MainTestEnv struct {
	TestDB *pgxpool.Pool
}

func SetupGlobal

func SetupGlobal(dbDsn string, dbMaxConns int,
	dbMaxIdletime string) (*MainTestEnv, error)

type MatrixTester

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

func CreateMatrixTester

func CreateMatrixTester(baseRequest RequestTester) MatrixTester

func (*MatrixTester) AddTestCaseCookieStatusCode

func (mt *MatrixTester) AddTestCaseCookieStatusCode(
	cookie *http.Cookie,
	statusCode int,
)

func (*MatrixTester) AddTestCaseErrorMessage

func (mt *MatrixTester) AddTestCaseErrorMessage(
	reqData any,
	errorMessage ErrorMessage,
)

func (*MatrixTester) AddTestCaseStatusCode

func (mt *MatrixTester) AddTestCaseStatusCode(query map[string]string, statusCode int)

func (MatrixTester) Do

func (mt MatrixTester) Do(t *testing.T)

type ParallelOperation

type ParallelOperation = func(t *testing.T, ts *httptest.Server)

type RequestTester

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

func CreateRequestTester

func CreateRequestTester(
	handler http.Handler,
	method, path string,
	pathValues ...any,
) RequestTester

func (*RequestTester) AddCookie

func (tReq *RequestTester) AddCookie(cookie *http.Cookie)

func (RequestTester) Copy

func (tReq RequestTester) Copy() RequestTester

func (RequestTester) Do

func (tReq RequestTester) Do(t *testing.T, rsData any) *http.Response

func (*RequestTester) SetQuery

func (tReq *RequestTester) SetQuery(query map[string]string)

func (*RequestTester) SetReqData

func (tReq *RequestTester) SetReqData(reqData any)

func (*RequestTester) SetTestServer

func (tReq *RequestTester) SetTestServer(ts *httptest.Server)

type Tx

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

func (Tx) Begin

func (tx Tx) Begin(ctx context.Context) (pgx.Tx, error)

func (Tx) Exec

func (tx Tx) Exec(
	ctx context.Context,
	sql string,
	arguments ...any,
) (pgconn.CommandTag, error)

func (Tx) Query

func (tx Tx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)

func (Tx) QueryRow

func (tx Tx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

type WebsocketTester

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

func CreateWebsocketTester

func CreateWebsocketTester(handler http.Handler) WebsocketTester

func (WebsocketTester) Do

func (tWeb WebsocketTester) Do(
	t *testing.T,
	initialResponse any,
	parallelOperationResponse any,
)

func (*WebsocketTester) SetInitialMessage

func (tWeb *WebsocketTester) SetInitialMessage(msg any)

func (*WebsocketTester) SetParallelOperation

func (tWeb *WebsocketTester) SetParallelOperation(parallelOperation ParallelOperation)

Jump to

Keyboard shortcuts

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