Documentation
¶
Index ¶
- func AssertAuditLogs(auditLogs model.AuditLogs, expectedAction model.AuditLogAction, ...) error
- func ModifyCookieAttribute(headers http.Header, attrKey, value string) http.Header
- func NewUUIDv4(t *testing.T) uuid.UUID
- func OverwriteQueryParamIfHeaderAndParamExist(headers http.Header, headerKey, paramKey, paramValue string) http.Header
- func ProcessResponse(t *testing.T, response *httptest.ResponseRecorder) (int, http.Header, string)
- func SortJSONArrayElements(t *testing.T, raw string) any
- func TestHandler(t *testing.T, methods []string, endpoint string, ...)
- func TestV2HandlerFailure(t *testing.T, methods []string, endpoint string, ...)
- func VerifyAuditLogs(dbInst database.Database, expectedAction model.AuditLogAction, ...) error
- type ExpectedResponse
- type RequestExecutor
- func (s *RequestExecutor) OnHandler(handler http.Handler) *RequestExecutor
- func (s *RequestExecutor) OnHandlerFunc(handler http.HandlerFunc) *RequestExecutor
- func (s *RequestExecutor) Request() *http.Request
- func (s *RequestExecutor) Require() RequestResponseAssertions
- func (s *RequestExecutor) WithBody(body any) *RequestExecutor
- func (s *RequestExecutor) WithContext(bhCtx *ctx.Context) *RequestExecutor
- func (s *RequestExecutor) WithHeader(key, value string) *RequestExecutor
- func (s *RequestExecutor) WithMethod(method string) *RequestExecutor
- func (s *RequestExecutor) WithURL(rawURL string, args ...any) *RequestExecutor
- func (s *RequestExecutor) WithURLPathVars(vars map[string]string) *RequestExecutor
- func (s *RequestExecutor) WithURLQueryVars(values url.Values) *RequestExecutor
- type RequestResponseAssertions
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 ¶
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 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 SortJSONArrayElements ¶
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 TestV2HandlerFailure ¶
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 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 (s *RequestExecutor) Require() RequestResponseAssertions
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