test

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertJsonEqual added in v0.13.3

func AssertJsonEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{}) bool

assert.Equal for JSON - more accurate comparison, pretty diff

func EmptyResponse added in v0.13.5

func EmptyResponse() string

func JsonCompact added in v0.13.3

func JsonCompact(jsonStr string) string

JsonCompact removes insignificant space characters from a JSON string It helps compare JSON strings without worrying about whitespace differences

func MockHTTPServer added in v0.13.3

func MockHTTPServer(requestChan chan *Request) *mockServer

MockHTTPServer creates an http server that can be used to test clients NOTE: if you want to make sure that you get requests in your requestChan one by one, limit the channel to a buffer size of 1. then writes to the chan will block until you read it. see ReqChan() for how to do this

func RandServerAddress added in v0.13.3

func RandServerAddress(t *testing.T) string

func ReqChan added in v0.13.3

func ReqChan() chan *Request

ReqChan makes a channel for reading received requests one by one. Use it in conjunction with MockHTTPServer

func ReqToStr added in v0.13.3

func ReqToStr(t *testing.T, req *jsonrpc.RPCRequest) string

ReqToStr stringifies a supplied RPCRequest

func ResToStr added in v0.13.3

func ResToStr(t *testing.T, res *jsonrpc.RPCResponse) string

ResToStr stringifies a supplied RPCResponse

func StrToReq added in v0.13.3

func StrToReq(t *testing.T, req string) *jsonrpc.RPCRequest

StrToReq creates an RPCRequest from a supplied string

func StrToRes added in v0.13.7

func StrToRes(t *testing.T, res string) *jsonrpc.RPCResponse

StrToRes creates an RPCResponse from a supplied string

Types

type Request added in v0.13.3

type Request struct {
	R    *http.Request
	W    http.ResponseWriter
	Body string
}

Jump to

Keyboard shortcuts

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