Documentation ¶
Index ¶
- func NewJSONRequest(ctx context.Context, method, url string, body interface{}) (*http.Request, error)
- func NewQueryRequest(ctx context.Context, method, url string, queries types.Map) (*http.Request, error)
- func NewUploadRequest(ctx context.Context, url string, file []byte, fields map[string]string) (*http.Request, error)
- func SendRequest(r *http.Request) (*http.Response, error)
- type InternalBody
- type Response
- func ExecuteTestCase[Body any](t *testing.T, tc *TestCase, engine *gin.Engine) *Response[InternalBody[Body]]
- func Get[Body any](ctx context.Context, url string) (*Response[Body], error)
- func ParseResponse[R any](ctx context.Context, r *http.Response) (*Response[R], error)
- func PostJSON[Body any](ctx context.Context, url string, body interface{}) (*Response[Body], error)
- type ResponseRecorder
- type TestCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewJSONRequest ¶
func NewJSONRequest(ctx context.Context, method, url string, body interface{}) (*http.Request, error)
NewJSONRequest creates new request with JSON body
func NewQueryRequest ¶
func NewQueryRequest(ctx context.Context, method, url string, queries types.Map) (*http.Request, error)
NewQueryRequest creates request with query strings
Types ¶
type InternalBody ¶
type InternalBody[R any] struct { Verdict string `json:"verdict"` Message string `json:"message"` Time time.Time `json:"time"` Data R `json:"data"` }
InternalBody defines struct for internal response body This is for communicate with internal services (rio exposed services)
type Response ¶
Response is generic response structure Body is data type of the response body
func ExecuteTestCase ¶
func ExecuteTestCase[Body any](t *testing.T, tc *TestCase, engine *gin.Engine) *Response[InternalBody[Body]]
ExecuteTestCase execute test case with gin engine
func ParseResponse ¶
ParseResponse parses an http response to struct
type ResponseRecorder ¶
type ResponseRecorder struct { *httptest.ResponseRecorder // contains filtered or unexported fields }
ResponseRecorder wraps recorder to support CloseNotify
func NewResponseRecorder ¶
func NewResponseRecorder() *ResponseRecorder
NewResponseRecorder returns a new instance
func (*ResponseRecorder) CloseNotify ¶
func (r *ResponseRecorder) CloseNotify() <-chan bool
CloseNotify waits for closed message This is required method for go-gin framework
Click to show internal directories.
Click to hide internal directories.