testutil

package
v0.0.0-...-eaa8ffa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package testutil 提供测试辅助工具

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertStatusCode

func AssertStatusCode(expected, actual int) bool

AssertStatusCode 断言状态码

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 响应

func SetupMockDB

func SetupMockDB() (*gorm.DB, sqlmock.Sqlmock, error)

SetupMockDB 创建 Mock 数据库连接

func SetupTestRouter

func SetupTestRouter() *gin.Engine

SetupTestRouter 创建测试用的 Gin 路由器

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址