Documentation
¶
Index ¶
- func Delete(t test.T, url string, respBody interface{}, apiToken string) int
- func DeleteWithoutBody(t test.T, url string, apiToken string) int
- func Get(t test.T, url string, respBody interface{}, apiToken string) int
- func GetWithoutBody(t test.T, url string, apiToken string) int
- func Post(t test.T, url string, reqBody interface{}, respBody interface{}, ...) int
- func Put(t test.T, url string, reqBody interface{}, respBody interface{}, ...) int
- func StartTestServer(routes []base.Routes, t test.T) (int, *app.ContextOut)
- func StartTestServerWithMiddleWare(middlewares base.Middlewares, routes []base.Routes, t test.T) (int, *app.ContextOut)
- func StopTestServer(appCtx *app.ContextOut, t test.T)
- func StringifyHandlerFunc(handlerFunc interface{}) string
- type HandlerFuncRegistrationOverride
- type MockResponseWriter
- type MockRoutesAgent
- type RouteVerifier
- type RouteVerifierFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteWithoutBody ¶
DeleteWithoutBody does DELETE request only expecting status code
func GetWithoutBody ¶
GetWithoutBody does GET request only expecting status code
func StartTestServer ¶
StartTestServer with specified routes. Returns chosen network port
func StartTestServerWithMiddleWare ¶
func StartTestServerWithMiddleWare(middlewares base.Middlewares, routes []base.Routes, t test.T) (int, *app.ContextOut)
StartTestServerWithMiddleWare with specified middlewares and routes. Returns chosen network port
func StopTestServer ¶
func StopTestServer(appCtx *app.ContextOut, t test.T)
StopTestServer gracefully
func StringifyHandlerFunc ¶
func StringifyHandlerFunc(handlerFunc interface{}) string
StringifyHandlerFunc for comparisons in testing
Types ¶
type HandlerFuncRegistrationOverride ¶
type HandlerFuncRegistrationOverride func(method string, url string, registered func(http.ResponseWriter, *http.Request)) interface{}
HandlerFuncRegistrationOverride function type
type MockResponseWriter ¶
type MockResponseWriter struct { // Header() HeaderReturn http.Header // Write() WriteBytesArg []byte WriteIntReturn int WriteErrorReturn error // WriteHeader() WriteHeaderStatusCodeArg int }
MockResponseWriter is a test friendly implementation of http.ResponseWriter
func (*MockResponseWriter) Header ¶
func (writer *MockResponseWriter) Header() http.Header
Header mocks 'http.ResponseWriter.Header() http.Header'
func (*MockResponseWriter) Write ¶
func (writer *MockResponseWriter) Write(bytes []byte) (int, error)
Write mocks 'http.ResponseWriter.Write([]byte) (int,error)'
func (*MockResponseWriter) WriteHeader ¶
func (writer *MockResponseWriter) WriteHeader(statusCode int)
WriteHeader mocks 'http.ResponseWriter.WriteHeader(int)'
type MockRoutesAgent ¶
type MockRoutesAgent interface { base.RoutesAgent OverrideHandlerFuncRegistration(HandlerFuncRegistrationOverride) VerifyThatRoute(t test.T, url string) RouteVerifierFactory }
MockRoutesAgent mocks base.RoutesAgent and adds test friendly features
func NewMockRoutesAgent ¶
func NewMockRoutesAgent() MockRoutesAgent
NewMockRoutesAgent with test friendly features
type RouteVerifier ¶
type RouteVerifier interface {
UsesHandler(interface{}) RouteVerifier
}
RouteVerifier is used to verify proper configuration of HTTP routes
type RouteVerifierFactory ¶
type RouteVerifierFactory interface {
ForHTTPMethod(string) RouteVerifier
}
RouteVerifierFactory creates RouteVerifier instances