test

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPResponseFromFile

func HTTPResponseFromFile(filename string) *http.Response

HTTPResponseFromFile creates a response object from the contents of a file. It uses to suffix of the filename to determine the content-type

Types

type APIRequest

type APIRequest struct {
	Headers          map[string]string
	Method           string
	Path             string
	RequestJSON      interface{} //if non-nil, will be encoded as JSON
	ExpectStatusCode int
	ExpectBody       *string //raw content (not a file path)
	ExpectJSON       string  //path to JSON file
	ExpectFile       string  //path to arbitrary file
}

APIRequest contains all metadata about a test request.

func (APIRequest) Check

func (r APIRequest) Check(t *testing.T, handler http.Handler)

Check performs the HTTP request described by this APIRequest against the given http.Handler and compares the response with the expectation in the APIRequest.

type HTTPRequestMatcher

type HTTPRequestMatcher struct {
	gomock.Matcher
	// ExpectHeader contains the required header fields and a regexp pattern to match
	ExpectHeader map[string]string
	// InjectHeader contains the new fields to be injected
	InjectHeader map[string]string
}

HTTPRequestMatcher matches against http.Request parameters Optionally it can check the header-contents and inject new header-fields as a side-effect

func (HTTPRequestMatcher) Matches

func (m HTTPRequestMatcher) Matches(x interface{}) bool

Matches checks for expected headers (precondition) and injects additional ones (postcondition)

func (HTTPRequestMatcher) String

func (m HTTPRequestMatcher) String() string

type TimeStringMatcher

type TimeStringMatcher struct {
	gomock.Matcher
}

TimeStringMatcher matches strings containing timestamps

func (TimeStringMatcher) Matches

func (m TimeStringMatcher) Matches(x interface{}) bool

Matches checks whether the string is a valid RFC3339 or Unix timestamp

func (TimeStringMatcher) String

func (m TimeStringMatcher) String() string

Directories

Path Synopsis
Command gocovcat combines multiple go cover runs, and prints the result on stdout.
Command gocovcat combines multiple go cover runs, and prints the result on stdout.

Jump to

Keyboard shortcuts

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