Documentation ¶
Index ¶
- func ErrToResponse(e error) (int, *entities.GoComError)
- func ParseIDParam(c *gin.Context, name string, p *presenter.Presenter) (entities.ID, bool)
- func RequireEqualJSON(t *testing.T, expected any, recorder *httptest.ResponseRecorder)
- func SetupGinTest(t *testing.T, method, path string, params gin.Params, body []byte) (*gin.Context, *httptest.ResponseRecorder)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrToResponse ¶ added in v0.3.0
func ErrToResponse(e error) (int, *entities.GoComError)
ErrToResponse checks if the provided error is a GoComError. If yes, status and embedded error message are returned. If no, status is 500 and provided error message are returned.
func ParseIDParam ¶ added in v0.3.0
ParseIDParam tries to parse parameter with the given name as an UUID or short ID. On failure, an error is set on the Gin context.
p := presenter.New() id, ok := ParseIDParam(c, "id", p) if !ok { return // Response already set on Gin context }
func RequireEqualJSON ¶ added in v0.3.0
func RequireEqualJSON(t *testing.T, expected any, recorder *httptest.ResponseRecorder)
RequireEqualJSON unmarshals the body from the provided recorder to the same type as expected. Next, it asserts this result against the expected value.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.