Documentation ¶
Overview ¶
Package restclienttest simplifying test restclient by wrapping `*httptest.Server`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RequestHandlers ¶
type RequestHandlers map[string]TestRequest
RequestHandlers mapped of handler, key is in form or `method:path`.
type TestRequest ¶
type TestRequest struct { Name string Test func(ass *assert.Assertions, r *http.Request) bool HeaderTest func(ass *assert.Assertions, headers http.Header) bool FormTest func(ass *assert.Assertions, forms url.Values) bool QueryTest func(ass *assert.Assertions, queries url.Values) bool ResponseFunc func(ass *assert.Assertions, w http.ResponseWriter) ResponseCode int ResponseHeader map[string][]string ResponseBody []byte }
TestRequest definition how to validate and respond of request. All `*Test` fields will be evaluated in sequence when not nil. `Responsefunc` field will be prioritized as over `ResponseCode`, `ResponseHeader`, and `ResponseBody`.
type TestServer ¶
TestServer contains dependencies needed for testing.
func NewTestServer ¶
func NewTestServer(t *testing.T) *TestServer
NewTestServer create a new `*TestServer` with provided `*testing.T`.
func (*TestServer) AppendHandler ¶
func (ts *TestServer) AppendHandler(method, path string, testRequest TestRequest)
AppendHandler append request based on `method` and `path` that will be handled with `testRequest`.
Click to show internal directories.
Click to hide internal directories.