test

package
v0.0.0-...-d1f9358 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ContentTypeJSON string associated with content-type json
	ContentTypeJSON = "application/json"
	//ContentTypeHTML string associated with content-type html
	ContentTypeHTML = "text/html"
)

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(tassert *assert.Assertions, wantErr bool, err error)

CheckErr checks if function returned error correctly

func EncodeJSON

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

EncodeJSON encodes json data in bytes

Types

type ContentType

type ContentType string

ContentType type for http Content-Type

type ExpectedResponse

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

ExpectedResponse stores expected responce basic data

type HTTPTest

type HTTPTest struct {
	*assert.Assertions
	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 responce 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