test_helper

package
v0.0.0-...-f7fdad9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRouter

func GetRouter(withTemplates bool) *gin.Engine

Helper function to create a router during testing

func MiddleWares

func MiddleWares() []gin.HandlerFunc

func RunRequest

func RunRequest(rc RequestConfig)

func RunSimpleGet

func RunSimpleGet(path string, handler RequestFunc, reply ResponseFunc)

func RunSimplePost

func RunSimplePost(path, body string, handler RequestFunc, reply ResponseFunc)

func TestHTTPResponse

func TestHTTPResponse(t *testing.T, r *gin.Engine, req *http.Request, f func(w *httptest.ResponseRecorder))

Helper function to process a request and test its response

func TestMain

func TestMain(m *testing.M)

func VerifyResponse

func VerifyResponse(r *httptest.ResponseRecorder, code int, data map[string]interface{}) (bool, error)

Types

type RequestConfig

type RequestConfig struct {
	Method      string
	Path        string
	Body        string
	Headers     map[string]string
	Middlewares []gin.HandlerFunc
	Handler     RequestFunc
	Finaliser   ResponseFunc
}

type RequestFunc

type RequestFunc func(*gin.Context)

type Response

type Response map[string]interface{}

func ParseJson

func ParseJson(body *bytes.Buffer) Response

type ResponseFunc

type ResponseFunc func(*httptest.ResponseRecorder)

response handling func type

Jump to

Keyboard shortcuts

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