Documentation ¶
Index ¶
- Variables
- func AssertEqualFuncs(t *testing.T, fn1, fn2 interface{})
- func AssertGetResponseBodyEquals(t *testing.T, port int, ssl bool, path string, exp string)
- func AssertMarshaledEquals(t *testing.T, m Marshalable, exp string)
- func AssertServerResponse(t *testing.T, callbacks *v1.Callbacks, ssl bool, path string, exp string)
- func CreateTestServer(t *testing.T, callbacks *v1.Callbacks, ssl bool) *server.HTTPAPI
- func GetFreePort() (int, error)
- func GetTestRequest(getURL string, params url.Values, h http.Handler) *httptest.ResponseRecorder
- func PostTestRequest(uri string, body io.Reader, h http.Handler) *httptest.ResponseRecorder
- func RequireGetFreePort(t *testing.T) int
- func RequireGetResponseBody(t *testing.T, port int, path string) []byte
- func RequireGetResponseBodySSL(t *testing.T, port int, path string) []byte
- func RequireTestCID(t *testing.T, data []byte) cid.Cid
- type Marshalable
Constants ¶
This section is empty.
Variables ¶
var HappyPathCallbacks = v1.Callbacks{
GetActorByID: gabid,
GetActorNonce: gan,
GetActors: ga,
GetBlockByID: gbid,
CreateMessage: cm,
}
HappyPathCallbacks provides a dummy set of callbacks (incomplete) for testing
Functions ¶
func AssertEqualFuncs ¶
AssertEqualFuncs compares two funcs for equality
func AssertGetResponseBodyEquals ¶
AssertGetResponseBodyEquals asserts that response body for a GET call using the provided arguments equals `exp`, when posted to a test server
func AssertMarshaledEquals ¶
func AssertMarshaledEquals(t *testing.T, m Marshalable, exp string)
AssertMarshaledEquals asserts that the marshaled version of the Marshalable `m` equals `exp`
func AssertServerResponse ¶
AssertServerResponse creates an http test server, sends a request and asserts that the response body is equal to `exp`
func CreateTestServer ¶
CreateTestServer creates a real http server for testing
func GetFreePort ¶
GetFreePort gets a free port from the kernel Credit: https://github.com/phayes/freeport
func GetTestRequest ¶
GetTestRequest sets up a request to uri with url params via httptest, calls the provided handler, and returns the new recorder with the response stored.
func PostTestRequest ¶
PostTestRequest sets up a post request to `uri` with a JSON `body`, calls the provided handler `h` and returns the new recorder with the response stored.
func RequireGetFreePort ¶
RequireGetFreePort fails the test if GetFreePort fails
func RequireGetResponseBody ¶
RequireGetResponseBody fails the test if getResponseBody fails, when posted to a test server
func RequireGetResponseBodySSL ¶
RequireGetResponseBodySSL fails the test if getResponseBody fails, when posted to a test server
func RequireTestCID ¶
RequireTestCID generates a new random cid.Cid
Types ¶
type Marshalable ¶
Marshalable is an interface that has a `MarshalJSON` func, for use by AssertMarshaledEquals