mock

package
v0.0.0-...-2acabb3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Engine

func Engine() (*xorm.Engine, sqlmock.Sqlmock)

Engine mock xorm engine 模拟xorm engine, 用于测试代码内部调用数据库时,模拟数据库的返回值

func GinContext

func GinContext(w *httptest.ResponseRecorder) *gin.Context

GinContext mock gin context use httptest.NewRecorder() to get mock w

func HTTPRequest

func HTTPRequest(c *gin.Context, method string, content interface{}, params gin.Params, u url.Values)

HTTPRequest mock http request 模拟各种http请求的上下文,用于测试http接口接到不同参数的请求时的处理逻辑 Example usage: HTTPRequest(c, "GET", nil, params, u) HTTPRequest(c, "POST", content, params, nil) HTTPRequest(c, "PUT", content, params, nil) HTTPRequest(c, "PATCH", content, params, nil) HTTPRequest(c, "DELETE", content, params, nil)

func HTTPResponse

func HTTPResponse(client *http.Client, url, method string, statusCode int, headers map[string][]string, responseBody string, cookies []*http.Cookie) func()

HTTPResponse mock http response 模拟第三方接口的返回值, 用于测试代码内部调用第三方接口时的逻辑

Types

This section is empty.

Jump to

Keyboard shortcuts

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