assert

package
v3.0.0-...-c77a060 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(t *testing.T, testName string, expected interface{}, actual interface{})

Equal asserts that expected and actual are equal according to reflect.DeepEqual

func NotEqual

func NotEqual(t *testing.T, testName string, unexpected interface{}, actual interface{})

NotEqual asserts that expected and actual are not equal according to reflect.DeepEqual

func URLValue

func URLValue(t *testing.T, testName string, urlValues url.Values, key, expectedValue string)

URLValue asserts that key->expectedValue is a key-value pair in the urlValues.

Types

type RequestAssertFunc

type RequestAssertFunc func(t *testing.T, testName string, r *http.Request)

A RequestAssertFunc takes a request object and makes assertions

func All

All runs all the assertions in sequence

func Auth

func Auth(tokenType string) RequestAssertFunc

Auth asserts that the right authorization header was put on the request

func Body

func Body(assertFunc func(t *testing.T, testName string, body string)) RequestAssertFunc

Body reads the request's body and checks it's the same as expected

func BodyFormValue

func BodyFormValue(key, expectedValue string) RequestAssertFunc

BodyFormValue returns a RequestAssertFunc that asserts that the body is form-encoded and has the key-value pair given.

func BodyString

func BodyString(expected string) RequestAssertFunc

BodyString returns a RequestAssertFunc that asserts that the request body

func BodyUnmarshal

func BodyUnmarshal(object interface{}, assertFunc func(*testing.T, string)) RequestAssertFunc

BodyUnmarshal returns a RequestAssertFunc that unmarshals the request body into object, then runs assertFunc. Note that assertFunc does not accept an object - this is because it is intended that you write assertFunc as a closure over your object.

func BodyUnmarshalEqual

func BodyUnmarshalEqual(expected map[string]interface{}) RequestAssertFunc

BodyUnmarshalEqual makes a RequestAssertFunc that reads the request body, unmarshals it, and checks the unmarshalled object is equal to expected. Remember that json treats all numbers as float64s! add a .0 to your numbers

func Method

func Method(expected string) RequestAssertFunc

Method reads the request's method and checks that it's the same as expected

func QueryValue

func QueryValue(key, expectedValue string) RequestAssertFunc

QueryValue asserts that the requests' query string has key=value.

func Unauthed

func Unauthed() RequestAssertFunc

Unauthed asserts that the request had no authorization header

Jump to

Keyboard shortcuts

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