handlertest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertErrorResponse

func AssertErrorResponse(t *testing.T, body []byte, expectedMessage string)

AssertErrorResponse checks if the error response contains the expected message

func AssertHTTPStatusCode

func AssertHTTPStatusCode(t *testing.T, got, want int)

AssertHTTPStatusCode checks if the status code is as expected

func CreateHealthRecordJSON

func CreateHealthRecordJSON(t *testing.T, date time.Time, stepCount int) string

CreateHealthRecordJSON creates a JSON representation of a health record

func CreateRequestContext

func CreateRequestContext(ctx context.Context, method, url, body string) *http.Request

CreateRequestContext creates an HTTP request with JSON content type for testing

func ExecuteHandlerRequest

func ExecuteHandlerRequest(t *testing.T, handler http.HandlerFunc, req *http.Request) *httptest.ResponseRecorder

ExecuteHandlerRequest executes a handler with the given request and returns the response

func ParseAPIDateFormat

func ParseAPIDateFormat(dateStr string) time.Time

ParseAPIDateFormat parses the date string(YYYY-MM-DD) from API request

func ParseJSONResponse

func ParseJSONResponse(t *testing.T, body []byte, target any)

ParseJSONResponse parses a JSON response body into the given target

func SetupMockDBWithRecords

func SetupMockDBWithRecords(t *testing.T, records []models.HealthRecord) *mock.MockDB

SetupMockDBWithRecords sets up a mock DB with the given records func SetupMockDBWithRecords(t *testing.T, records ...*models.HealthRecord) *mock.MockDB {

Types

This section is empty.

Jump to

Keyboard shortcuts

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