Documentation
¶
Index ¶
- func AssertEqual(t *testing.T, expected, actual any)
- func AssertError(t *testing.T, err error)
- func AssertFalse(t *testing.T, value bool)
- func AssertNil(t *testing.T, value any)
- func AssertNoError(t *testing.T, err error)
- func AssertNotNil(t *testing.T, value any)
- func AssertTrue(t *testing.T, value bool)
- func SetupRouter() *gin.Engine
- type MockCache
- type MockDB
- type MockStorage
- type Request
- func DELETE(router *gin.Engine, path string) *Request
- func GET(router *gin.Engine, path string) *Request
- func NewRequest(router *gin.Engine, method, path string) *Request
- func PATCH(router *gin.Engine, path string) *Request
- func POST(router *gin.Engine, path string) *Request
- func PUT(router *gin.Engine, path string) *Request
- type Response
- func (r *Response) AssertBadRequest(t *testing.T)
- func (r *Response) AssertCreated(t *testing.T)
- func (r *Response) AssertForbidden(t *testing.T)
- func (r *Response) AssertJSONContains(t *testing.T, key string, expected any)
- func (r *Response) AssertNotFound(t *testing.T)
- func (r *Response) AssertOK(t *testing.T)
- func (r *Response) AssertStatus(t *testing.T, expected int)
- func (r *Response) AssertUnauthorized(t *testing.T)
- func (r *Response) ParseJSON(v any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MockStorage ¶
type MockStorage struct {
// contains filtered or unexported fields
}
MockStorage 模拟存储
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request 测试请求辅助函数
func NewRequest ¶
NewRequest 创建测试请求
func (*Request) WithHeader ¶
WithHeader 设置请求头
type Response ¶
type Response struct {
*httptest.ResponseRecorder
}
Response 响应解析辅助
func (*Response) AssertBadRequest ¶
AssertBadRequest 断言状态码为 400
func (*Response) AssertCreated ¶
AssertCreated 断言状态码为 201
func (*Response) AssertForbidden ¶
AssertForbidden 断言状态码为 403
func (*Response) AssertJSONContains ¶
AssertJSONContains 断言 JSON 包含指定字段
func (*Response) AssertNotFound ¶
AssertNotFound 断言状态码为 404
func (*Response) AssertStatus ¶
AssertStatus 断言状态码
func (*Response) AssertUnauthorized ¶
AssertUnauthorized 断言状态码为 401
Click to show internal directories.
Click to hide internal directories.