test

package
v0.0.0-...-ec844c3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAuditLogs

func AssertAuditLogs(auditLogs model.AuditLogs, expectedAction model.AuditLogAction, expectedResultStatus model.AuditLogEntryStatus, expectedData model.AuditData) error

func ModifyCookieAttribute

func ModifyCookieAttribute(headers http.Header, attrKey, value string) http.Header

ModifyCookieAttribute searches the provided HTTP headers and updates the specified cookie attribute (e.g., "Secure", "SameSite", "Path") to a new value. If the attribute is found in a cookie string, its value is replaced with the provided value. Cookies that do not contain the specified attribute are left unchanged.

func NewUUIDv4

func NewUUIDv4(t *testing.T) uuid.UUID

func OverwriteQueryParamIfHeaderAndParamExist

func OverwriteQueryParamIfHeaderAndParamExist(headers http.Header, headerKey, paramKey, paramValue string) http.Header

OverwriteQueryParamIfHeaderAndParamExist updates paramKey in the query string value of headerKey only if both the header and the parameter exist. Otherwise, it leaves the header untouched.

func ProcessResponse

func ProcessResponse(t *testing.T, response *httptest.ResponseRecorder) (int, http.Header, string)

func SortJSONArrayElements

func SortJSONArrayElements(t *testing.T, raw string) any

SortJSONArrayElements parses JSON and recursively sorts all arrays so their order doesn't affect equality. Returns the raw string if the input is not valid JSON.

Use this to normalize JSON bodies in tests where slice order is nondeterministic.

func TestHandler

func TestHandler(t *testing.T, methods []string, endpoint string, handler func(http.ResponseWriter, *http.Request), req http.Request, expected ExpectedResponse)

func TestV2HandlerFailure

func TestV2HandlerFailure(t *testing.T, methods []string, endpoint string, handler func(http.ResponseWriter, *http.Request), req http.Request, expected api.ErrorWrapper)

func VerifyAuditLogs

func VerifyAuditLogs(dbInst database.Database, expectedAction model.AuditLogAction, expectedField, expectedFieldValue string) error

VerifyAuditLogs Assumes success status for audit log

Types

type ExpectedResponse

type ExpectedResponse struct {
	Code int
	Body any
}

type RequestExecutor

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

func Request

func Request(t *testing.T) *RequestExecutor

func (*RequestExecutor) OnHandler

func (s *RequestExecutor) OnHandler(handler http.Handler) *RequestExecutor

func (*RequestExecutor) OnHandlerFunc

func (s *RequestExecutor) OnHandlerFunc(handler http.HandlerFunc) *RequestExecutor

func (*RequestExecutor) Request

func (s *RequestExecutor) Request() *http.Request

func (*RequestExecutor) Require

func (*RequestExecutor) WithBody

func (s *RequestExecutor) WithBody(body any) *RequestExecutor

func (*RequestExecutor) WithContext

func (s *RequestExecutor) WithContext(bhCtx *ctx.Context) *RequestExecutor

func (*RequestExecutor) WithHeader

func (s *RequestExecutor) WithHeader(key, value string) *RequestExecutor

func (*RequestExecutor) WithMethod

func (s *RequestExecutor) WithMethod(method string) *RequestExecutor

func (*RequestExecutor) WithURL

func (s *RequestExecutor) WithURL(rawURL string, args ...any) *RequestExecutor

func (*RequestExecutor) WithURLPathVars

func (s *RequestExecutor) WithURLPathVars(vars map[string]string) *RequestExecutor

func (*RequestExecutor) WithURLQueryVars

func (s *RequestExecutor) WithURLQueryVars(values url.Values) *RequestExecutor

type RequestResponseAssertions

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

func (RequestResponseAssertions) ResponseJSONBody

func (s RequestResponseAssertions) ResponseJSONBody(body any) RequestResponseAssertions

func (RequestResponseAssertions) ResponseStatusCode

func (s RequestResponseAssertions) ResponseStatusCode(status int) RequestResponseAssertions

Jump to

Keyboard shortcuts

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