matchers

package
v1.16.0-beta8 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainHeaderKeys added in v1.15.12

func ContainHeaderKeys(keys []string) types.GomegaMatcher

ContainHeaders produces a matcher that will only match if all provided header keys exist.

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 HaveMedianLessThan added in v1.15.0

func HaveMedianLessThan(upperBound time.Duration) types.GomegaMatcher

HaveMedianLessThan returns a matcher requiring the given slice of durations have a median value less than the given upperBound

func HaveOkResponse

func HaveOkResponse() types.GomegaMatcher

HaveOkResponse expects a http response with a 200 status code

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 HavePercentileLessThan added in v1.15.0

func HavePercentileLessThan(percentile int, upperBound time.Duration) types.GomegaMatcher

HavePercentileLessThan returns a matcher requiring the given slice of durations to be less than the given upperBound at the given percentile

func HavePercentileWithin added in v1.15.0

func HavePercentileWithin(percentile int, target, window time.Duration) types.GomegaMatcher

HavePercentileWithin returns a matcher requiring the given slice of durations to be within a window of a given target at the given percentile

func HaveStatusCode

func HaveStatusCode(statusCode int) types.GomegaMatcher

HaveStatusCode expects a http response with a particular status code

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
	// 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