matchers

package
v1.14.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainHeaders

func ContainHeaders(headers http.Header) types.GomegaMatcher

ContainHeaders produces a matcher that will only match if all provided headers are completely accounted for, including multi-value headers.

func ContainSubstrings

func ContainSubstrings(substrings []string) types.GomegaMatcher

ContainSubstrings produces a matcher that will match if all provided strings occur within the targeted string

func HaveExactResponseBody

func HaveExactResponseBody(body string) types.GomegaMatcher

HaveExactResponseBody expects a 200 response with a body that matches the provided string

func HaveHttpResponse

func HaveHttpResponse(expected *HttpResponse) types.GomegaMatcher

HaveHttpResponse returns a GomegaMatcher which validates that an http.Response contains particular expected properties (status, body..etc) If an expected body isn't defined, we default to expecting an empty response

func HaveOkResponse

func HaveOkResponse() types.GomegaMatcher

HaveOkResponse expects a 200 response with an empty body

func HaveOkResponseWithHeaders

func HaveOkResponseWithHeaders(headers map[string]interface{}) types.GomegaMatcher

HaveOkResponseWithHeaders expects an 200 response with a set of headers that match the provided headers

func HavePartialResponseBody

func HavePartialResponseBody(substring string) types.GomegaMatcher

HavePartialResponseBody expects a 200 response with a body that contains the provided substring

func HaveStatusCode

func HaveStatusCode(statusCode int) types.GomegaMatcher

HaveStatusCode expects an http response with a particular status code and an empty body

Types

type BeEquivalentToDiffMatcher

type BeEquivalentToDiffMatcher struct {
	matchers.BeEquivalentToMatcher
}

func BeEquivalentToDiff

func BeEquivalentToDiff(expected interface{}) *BeEquivalentToDiffMatcher

BeEquivalentToDiff is the same as BeEquivalentTo but prints a nice diff on failure best effect use ginkgo with -noColor

func (*BeEquivalentToDiffMatcher) FailureMessage

func (matcher *BeEquivalentToDiffMatcher) FailureMessage(actual interface{}) (message string)

func (*BeEquivalentToDiffMatcher) NegatedFailureMessage

func (matcher *BeEquivalentToDiffMatcher) NegatedFailureMessage(actual interface{}) (message string)

type HaveHttpResponseMatcher

type HaveHttpResponseMatcher struct {
	Expected *HttpResponse
	matchers.HaveHTTPStatusMatcher
	matchers.HaveHTTPBodyMatcher
	// contains filtered or unexported fields
}

func (*HaveHttpResponseMatcher) FailureMessage

func (m *HaveHttpResponseMatcher) FailureMessage(actual interface{}) (message string)

func (*HaveHttpResponseMatcher) Match

func (m *HaveHttpResponseMatcher) Match(actual interface{}) (success bool, err error)

func (*HaveHttpResponseMatcher) NegatedFailureMessage

func (m *HaveHttpResponseMatcher) NegatedFailureMessage(actual interface{}) (message string)

type HttpResponse

type HttpResponse struct {
	// StatusCode is the expected status code for an http.Response
	// Required
	StatusCode int
	// Body is the expected response body for an http.Response
	// Body can be of type: {string, bytes, GomegaMatcher}
	// Optional: If not provided, defaults to an empty string
	Body interface{}
	// Headers is the set of expected header values for an http.Response
	// Each header can be of type: {string, GomegaMatcher}
	// Optional: If not provided, does not perform header validation
	Headers map[string]interface{}
	// Custom is a generic matcher that can be applied to validate any other properties of an http.Response
	// Optional: If not provided, does not perform additional validation
	Custom types.GomegaMatcher
}

HttpResponse defines the set of properties that we can validate from an http.Response

Jump to

Keyboard shortcuts

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