gtu

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Unlicense Imports: 6 Imported by: 0

README

Gin Test Util

Exmaple: util_test.go

Documentation

Index

Constants

View Source
const (
	GET     = "GET"
	HEAD    = "HEAD"
	POST    = "POST"
	PUT     = "PUT"
	PATCH   = "PATCH"
	DELETE  = "DELETE"
	TRACE   = "TRACE"
	OPTIONS = "OPTIONS"
)

Variables

This section is empty.

Functions

func JSONAPI

func JSONAPI(
	t *testing.T,
	engine *gin.Engine,
	method string, url string, body io.Reader,
	expectedResponse interface{},
	validate ValidationFuncForJSONAPI,
	options ...RequestOption,
)

func Simple

func Simple(
	t *testing.T,
	engine *gin.Engine,
	method string, url string, body io.Reader,
	validate ValidationFunc,
	options ...RequestOption,
)

Types

type RequestOption

type RequestOption func(r *http.Request)

func HeaderOption

func HeaderOption(header map[string]string) RequestOption

func QueryOption

func QueryOption(query map[string]string) RequestOption

type ValidationFunc

type ValidationFunc func(t *testing.T, resp *httptest.ResponseRecorder)

type ValidationFuncForJSONAPI

type ValidationFuncForJSONAPI func(t *testing.T, expectedResponse interface{})

Jump to

Keyboard shortcuts

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