unittest

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJSONRequest

func NewJSONRequest(ctx context.Context, method, url string, data interface{}) (*http.Request, error)

NewJSONRequest creates a http.Request with json Content-Type. The data parameter can be io.Reader, []byte or a struct.

func NewTestService

func NewTestService(apiStyle service.APIStyle, desc ...interface{}) (service.Service, error)

NewTestService creates a service.Service for testing.

func NewTestServiceWithConfig

func NewTestServiceWithConfig(apiStyle service.APIStyle, desc []interface{}, modifier service.DefinitionModifier,
	filters []service.Filter) (service.Service, error)

NewTestServiceWithConfig creates a service.Service for testing with user specified modifier and filters. If modifier or filters is nil, default option will be used.

Types

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter
	Code() int
	Bytes() []byte
}

ResponseWriter mocks http.ResponseWriter and records response for testing

func NewResponseWriter

func NewResponseWriter() ResponseWriter

NewResponseWriter creates a new ResponseWriter

Jump to

Keyboard shortcuts

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