test

package
v0.0.0-...-4670381 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertCorsHeaders

func AssertCorsHeaders(t *testing.T, res *http.Response, methods string)

AssertCorsHeaders asserts that the response 'res' contains the expect CORS headers and values; including the endpoint dependent 'methods'.

func AssertDefaultHeaders

func AssertDefaultHeaders(t *testing.T, res *http.Response, contentType, methods string)

AssertDefaultHeaders asserts that the response 'res' default headers exist. This includes the value of dynamic headers 'contentType' and CORS 'methods'

func AssertEmptyBody

func AssertEmptyBody(t *testing.T, body io.Reader)

AssertEmptyBody asserts that a response 'body' is empty.

func AssertErrorBody

func AssertErrorBody(t *testing.T, body io.Reader) wrapped.WrappedReply

AssertErrorBody assert that a response 'body' is a generic response error. Returns the parsed response error.

func AssertNotEmptyBody

func AssertNotEmptyBody(t *testing.T, body io.Reader) []byte

AssertNotEmptyBody asserts that a response 'body' is NOT empty. The body is returned.

func CallWithJSON

func CallWithJSON(method string, url string, data interface{}) *http.Response

CallWithJSON calls an API endpoint with the specified details.

func PrintBody

func PrintBody(t *testing.T, res *http.Response) io.Reader

PrintBody parses the body of response 'res' and prints it to the test logs returning a new reader for the data.

func PrintResponse

func PrintResponse(t *testing.T, body io.Reader)

PrintResponse prints the 'body' of a response to the test logs.

func PrintTestDescription

func PrintTestDescription(t *testing.T, desc string)

PrintTestDescription prints the test description to the test logs.

func SetWorkingDir

func SetWorkingDir(binDir string)

SetWorkingDir sets the working directory so the server has access to resources.

func VerifyBadMethods

func VerifyBadMethods(t *testing.T, url string, corsMethods string, badMethods []string)

VerifyBadMethods asserts that for a specific 'url', the 'corsMethods' are as expected and an error response is returned when each value of 'badMethods' is used in an API call.

Types

type APICall

type APICall struct {
	URL    string
	Method string
	Body   io.Reader
}

APICall represents a single call to an API

func (*APICall) Fire

func (c *APICall) Fire() *http.Response

fire allows a built APICall to be actioned

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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