gin_mock

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMethodNotSupported = fmt.Errorf("method is not supported")
	ErrMIMENotSupported   = fmt.Errorf("mime is not supported")
	ErrNotSetTesting      = fmt.Errorf("please set testing.T")
)

Functions

func MockEngine

func MockEngine(init func(engine *gin.Engine) error) *gin.Engine

MockEngine for unit test

Types

type GinMock

type GinMock interface {
	FullUrl() string

	Method(method string) GinMock

	Query(query interface{}) GinMock

	Body(body io.Reader) GinMock

	BodyForm(param interface{}) GinMock

	BodyJson(body interface{}) GinMock

	Request() *http.Request

	BodyFileSingleForm(fileName string, fieldName string, param interface{}) GinMock

	Header(header map[string]string) GinMock

	NewRecorder() *httptest.ResponseRecorder
}

func NewGinMock

func NewGinMock(t *testing.T, router *gin.Engine, baseUrl string, url string) GinMock

NewGinMock

  • router: gin.Engine
  • baseUrl: is the base url of the server, will trim the last "/"
  • url: is the url of the request

Jump to

Keyboard shortcuts

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