testutils

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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