testUtil

package
v0.0.0-...-4f336d7 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package testUtil has helpers to be used with unit tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(tb testing.TB, condition bool, msg string, v ...interface{})

Assert fails the test if the condition is false. Code was copied from https://github.com/benbjohnson/testing MIT license

func CreateDeleteTestRequestServer

func CreateDeleteTestRequestServer(t *testing.T, expectedAuthTokenValue string, urlEndsWith string) *httptest.Server

CreateDeleteTestRequestServer creates a http.Server that can be used to test Delete requests.

func CreateGetJSONTestRequestServer

func CreateGetJSONTestRequestServer(t *testing.T, expectedAuthTokenValue string, jsonResponsePayload string, verifyRequest func(*http.Request)) *httptest.Server

CreateGetJSONTestRequestServer creates a httptest.Server that can be used to test GetJson requests. Just specify the token, json payload that is to be read by the response, and a verification func that can be used to do additional validation of the request that is built

func CreateGetJsonTestServer

func CreateGetJsonTestServer(
	t *testing.T,
	expectedAuthToken string,
	jsonResponsePayload string,
	verifyRequest func(*http.Request)) *httptest.Server

CreateGetJSONTestServer creates a httptest.Server that can be used to test JSON Get requests. Takes a token, JSON payload, and a verification function to do additional validation

func CreatePostJSONTestRequestServer

func CreatePostJSONTestRequestServer(t *testing.T, expectedAuthTokenValue string, outputResponseJSONPayload string, expectedRequestURLEndsWith string, expectedRequestBody string) *httptest.Server

CreatePostJSONTestRequestServer creates a http.Server that can be used to test PostJson requests. Specify the token, response json payload and the url and request body that is expected.

func Equals

func Equals(tb testing.TB, exp, act interface{})

Equals fails the test if exp is not equal to act. Code was copied from https://github.com/benbjohnson/testing MIT license

func IsNil

func IsNil(tb testing.TB, act interface{})

IsNil ensures that the act interface is nil otherwise an error is raised.

Types

This section is empty.

Jump to

Keyboard shortcuts

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