Documentation
¶
Overview ¶
Package testutil 提供测试辅助工具
Index ¶
- func AssertStatusCode(expected, actual int) bool
- func HTTPRequest(router *gin.Engine, method, path string, body interface{}) *httptest.ResponseRecorder
- func HTTPRequestWithHeaders(router *gin.Engine, method, path string, body interface{}, ...) *httptest.ResponseRecorder
- func ParseJSONResponse(w *httptest.ResponseRecorder) (map[string]interface{}, error)
- func SetupMockDB() (*gorm.DB, sqlmock.Sqlmock, error)
- func SetupTestRouter() *gin.Engine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPRequest ¶
func HTTPRequest(router *gin.Engine, method, path string, body interface{}) *httptest.ResponseRecorder
HTTPRequest 发起 HTTP 测试请求
func HTTPRequestWithHeaders ¶
func HTTPRequestWithHeaders(router *gin.Engine, method, path string, body interface{}, headers map[string]string) *httptest.ResponseRecorder
HTTPRequestWithHeaders 发起带有自定义头的 HTTP 测试请求
func ParseJSONResponse ¶
func ParseJSONResponse(w *httptest.ResponseRecorder) (map[string]interface{}, error)
ParseJSONResponse 解析 JSON 响应
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.