testutils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentTypeJSON string associated with content-type json
	ContentTypeJSON contentType = "application/json"

	// ContentTypeHTML string associated with content-type html
	ContentTypeHTML contentType = "text/html"

	// ContentTypePlain
	ContentTypePlain contentType = "text/plain; charset=utf-8"
)

Variables

This section is empty.

Functions

func EncodeJSON

func EncodeJSON(data interface{}) ([]byte, error)

EncodeJSON encodes json data in bytes

func EncodeString

func EncodeString(data interface{}) ([]byte, error)

EncodeJSON encodes json data in bytes

Types

type ExpectedResponse

type ExpectedResponse struct {
	StatusCode   int
	ResponseType contentType
	Body         interface{}
}

ExpectedResponse stores expected response basic data

type HTTPTest

type HTTPTest struct {
	*testing.T
	Encoder func(interface{}) ([]byte, error)
}

HTTPTest encapsulates data for testing needs

func (*HTTPTest) CompareHTTPResponse

func (test *HTTPTest) CompareHTTPResponse(rr *httptest.ResponseRecorder, expected ExpectedResponse)

CompareHTTPResponse compares expected response with real one

func (*HTTPTest) CreateHTTPRequest

func (test *HTTPTest) CreateHTTPRequest(request Request) *http.Request

CreateHTTPRequest creates http Request with basic data

type Request

type Request struct {
	Method string
	URL    string
	Body   interface{}
}

Request stores http Request basic data

Jump to

Keyboard shortcuts

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