Documentation
¶
Overview ¶
Package testutil 提供测试共享工具
Index ¶
- func DoRequest(router *gin.Engine, method, path string, body ...http.Handler) *httptest.ResponseRecorder
- func DoRequestWithBody(t *testing.T, router *gin.Engine, method, path string, body []byte) *httptest.ResponseRecorder
- func RequireStatus(t *testing.T, w *httptest.ResponseRecorder, expected int)
- func SetupTestDB(t *testing.T, models ...interface{}) *gorm.DB
- func SetupTestRouter(t *testing.T) *gin.Engine
- func TestLogger() *zap.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoRequest ¶
func DoRequest(router *gin.Engine, method, path string, body ...http.Handler) *httptest.ResponseRecorder
DoRequest 执行 HTTP 请求并返回响应记录器
func DoRequestWithBody ¶
func DoRequestWithBody(t *testing.T, router *gin.Engine, method, path string, body []byte) *httptest.ResponseRecorder
DoRequestWithBody 执行带 body 的 HTTP 请求
func RequireStatus ¶
func RequireStatus(t *testing.T, w *httptest.ResponseRecorder, expected int)
RequireStatus 断言 HTTP 响应状态码
func SetupTestDB ¶
SetupTestDB 创建内存 SQLite 测试数据库并自动迁移给定模型
func SetupTestRouter ¶
SetupTestRouter 创建测试模式的 gin 路由器
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.