test

package
v0.0.0-...-dec31c8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: Apache-2.0, MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func AssertEqualFuncs(t *testing.T, fn1, fn2 interface{})

AssertEqualFuncs compares two funcs for equality

func AssertGetResponseBodyEquals

func AssertGetResponseBodyEquals(t *testing.T, port int, ssl bool, path string, exp string)

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

func AssertServerResponse(t *testing.T, callbacks *v1.Callbacks, ssl bool, path string, exp string)

AssertServerResponse creates an http test server, sends a request and asserts that the response body is equal to `exp`

func CreateTestServer

func CreateTestServer(t *testing.T, callbacks *v1.Callbacks, ssl bool) *server.HTTPAPI

CreateTestServer creates a real http server for testing

func GetFreePort

func GetFreePort() (int, error)

GetFreePort gets a free port from the kernel Credit: https://github.com/phayes/freeport

func GetTestRequest

func GetTestRequest(getURL string, params url.Values, h http.Handler) *httptest.ResponseRecorder

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

func PostTestRequest(uri string, body io.Reader, h http.Handler) *httptest.ResponseRecorder

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

func RequireGetFreePort(t *testing.T) int

RequireGetFreePort fails the test if GetFreePort fails

func RequireGetResponseBody

func RequireGetResponseBody(t *testing.T, port int, path string) []byte

RequireGetResponseBody fails the test if getResponseBody fails, when posted to a test server

func RequireGetResponseBodySSL

func RequireGetResponseBodySSL(t *testing.T, port int, path string) []byte

RequireGetResponseBodySSL fails the test if getResponseBody fails, when posted to a test server

func RequireTestCID

func RequireTestCID(t *testing.T, data []byte) cid.Cid

RequireTestCID generates a new random cid.Cid

Types

type Marshalable

type Marshalable interface {
	MarshalJSON() ([]byte, error)
}

Marshalable is an interface that has a `MarshalJSON` func, for use by AssertMarshaledEquals

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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