Documentation ¶
Index ¶
- func ErrorVerifier(env string, pkg string, file string, class string, function string, line int, ...) func(*utils.GError)
- func GenerateResponse(request *http.Request, code int, item string) *http.Response
- func InnerErrorPrefixSuffixVerifier(prefix string, suffix string) func(error)
- func InnerErrorVerifier(message string) func(error)
- func InnerGErrorVerifier(env string, pkg string, file string, class string, function string, line int, ...) func(error)
- func ItemIsNil[T any](item T)
- func NewTestClient(shouldFail bool, fns ...func(*http.Request) *http.Response) *http.Client
- func NoInnerError() func(error)
- func VerifyAndGenerateResponse(method string, uri string, code int, data string) func(*http.Request) *http.Response
- func VerifyList[T any](actual []T, verifiers ...func(T))
- func VerifyRequest(req *http.Request, method string, uri string)
- type ErrorReader
- type RoundTripFunc
- type StringMatch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorVerifier ¶
func ErrorVerifier(env string, pkg string, file string, class string, function string, line int, innerVerifier func(error), message string, msgParts ...string) func(*utils.GError)
ErrorVerifier verifies the fields on a backend Error
func GenerateResponse ¶
GenerateResponse creates an HTTP response we can use in our testing
func InnerErrorPrefixSuffixVerifier ¶
InnerErrorPrefixSuffixVerifier verifies that an error message has a given prefix and suffix
func InnerErrorVerifier ¶
InnerErrorVerifier verifies an error message
func InnerGErrorVerifier ¶ added in v1.1.53
func InnerGErrorVerifier(env string, pkg string, file string, class string, function string, line int, innerVerifier func(error), message string, msgParts ...string) func(error)
InnerGErrorVerifier can be used for the case when the inner error is a GError
func ItemIsNil ¶
func ItemIsNil[T any](item T)
ItemIsNil is a function that verifies that the data sent to it is nil
func NewTestClient ¶
NewTestClient returns an HTTP client with the transport replaced to avoid make real HTTP requests against the endpionts sent to it
func NoInnerError ¶
func NoInnerError() func(error)
NoInnerError verifies that an error did not occur
func VerifyAndGenerateResponse ¶
func VerifyAndGenerateResponse(method string, uri string, code int, data string) func(*http.Request) *http.Response
VerifyAndGenerateResponse verifies the HTTP request and generates an HTTP response
func VerifyList ¶ added in v1.1.39
func VerifyList[T any](actual []T, verifiers ...func(T))
VerifyList verifies that the number of items and the fields on each item
Types ¶
type ErrorReader ¶
type ErrorReader int
ErrorReader is a mock type we'll use in place of a reader so we can test out errors when Read is called
type RoundTripFunc ¶
type RoundTripFunc struct { Functions []func(*http.Request) *http.Response Index int ShouldFail bool }
RoundTripFunc allows us to encapsulate the functionality necessary to mock HTTP requests made from an HTTP client so we can test our request functions
type StringMatch ¶
StringMatch allows for matching a string argument based on a prefix and suffix
func NewStringMatch ¶
func NewStringMatch(prefix string, suffix string, contains ...string) StringMatch
NewStringMatch creates a new string match from the expected prefix, suffix and any values that should be contained in the string