Documentation ¶
Overview ¶
Package testing provides utilities for testing smith clients and protocols.
Index ¶
- Constants
- func AssertHasHeader(t T, expect, actual http.Header) bool
- func AssertHasHeaderKeys(t T, keys []string, actual http.Header) bool
- func AssertHasQuery(t T, expect, actual []QueryItem) bool
- func AssertHasQueryKeys(t T, keys []string, actual []QueryItem) bool
- func AssertJSONEqual(t T, expect, actual []byte) bool
- func AssertNotHaveHeaderKeys(t T, keys []string, actual http.Header) bool
- func AssertNotHaveQueryKeys(t T, keys []string, actual []QueryItem) bool
- func AssertURLFormEqual(t T, expect, actual []byte) bool
- func AssertXMLEqual(t T, expect, actual []byte) bool
- func CompareCBOR(actual io.Reader, expect64 string) error
- func CompareCompressedBytes(expect *bytes.Buffer, actual io.Reader, disable bool, min int64, ...) error
- func CompareJSONReaderBytes(r io.Reader, expect []byte) error
- func CompareReaderBytes(r io.Reader, expect []byte) error
- func CompareReaderEmpty(r io.Reader) error
- func CompareReaders(expect, actual io.Reader) error
- func CompareURLFormReaderBytes(r io.Reader, expect []byte) error
- func CompareValues(expect, actual interface{}, _ ...interface{}) error
- func CompareXMLReaderBytes(r io.Reader, expect []byte) error
- func GzipCompareCompressBytes(expect []byte, actual io.Reader) error
- func HasHeader(expect, actual http.Header) error
- func HasHeaderKeys(keys []string, actual http.Header) error
- func HasQuery(expect, actual []QueryItem) error
- func HasQueryKeys(keys []string, actual []QueryItem) error
- func JSONEqual(expectBytes, actualBytes []byte) error
- func NotHaveHeaderKeys(keys []string, actual http.Header) error
- func NotHaveQueryKeys(keys []string, actual []QueryItem) error
- func URLFormEqual(expectBytes, actualBytes []byte) error
- func XMLEqual(expectBytes, actualBytes []byte) error
- type ByteLoop
- type QueryItem
- type T
Constants ¶
const (
GZIP = "gzip"
)
Enumeration values for supported compress Algorithms.
Variables ¶
This section is empty.
Functions ¶
func AssertHasHeader ¶
AssertHasHeader compares the header values and identifies if the actual header set includes all values specified in the expect set. Emits a testing error, and returns false if the headers are not equal.
func AssertHasHeaderKeys ¶
AssertHasHeaderKeys validates that header set contains all keys expected. Emits a testing error, and returns false if the headers are not equal.
func AssertHasQuery ¶
AssertHasQuery validates that the expected set of query items are present in the actual set. Emits a testing error, and returns false if any of the expected set are not found in the actual.
func AssertHasQueryKeys ¶
AssertHasQueryKeys validates that the actual set of query items contains the keys provided. Emits a testing error if any key is not found.
func AssertJSONEqual ¶
AssertJSONEqual compares two JSON documents and identifies if the documents contain the same values. Emits a testing error, and returns false if the documents are not equal.
func AssertNotHaveHeaderKeys ¶
AssertNotHaveHeaderKeys validates that header set does not contains any of the keys. Emits a testing error, and returns false if the header contains the any of the keys equal.
func AssertNotHaveQueryKeys ¶
AssertNotHaveQueryKeys validates that the actual set of query items does not contains the keys provided. Emits a testing error if any key is found.
func AssertURLFormEqual ¶
AssertURLFormEqual compares two URLForm documents and identifies if the documents contain the same values. Emits a testing error, and returns false if the documents are not equal.
func AssertXMLEqual ¶
AssertXMLEqual compares two XML documents and identifies if the documents contain the same values. Emits a testing error, and returns false if the documents are not equal.
func CompareCBOR ¶ added in v1.20.2
CompareCBOR checks whether two CBOR values are equivalent.
The function signature is tailored for use in smithy protocol tests, where the expected encoding is given in base64, and the actual value to check is passed from the mock HTTP request body.
func CompareCompressedBytes ¶ added in v1.19.0
func CompareCompressedBytes(expect *bytes.Buffer, actual io.Reader, disable bool, min int64, algorithm string) error
CompareCompressedBytes compares the request stream before and after possible request compression
func CompareJSONReaderBytes ¶
CompareJSONReaderBytes compares the reader containing serialized JSON document. Deserializes the JSON documents to determine if they are equal. Return an error if the two JSON documents are not equal.
func CompareReaderBytes ¶
CompareReaderBytes compares the reader with the expected bytes. Returns an error if the two bytes are not equal.
func CompareReaderEmpty ¶
CompareReaderEmpty checks if the reader is nil, or contains no bytes. Returns an error if not empty.
func CompareReaders ¶
CompareReaders two io.Reader values together to determine if they are equal. Will read the contents of the readers until they are empty.
func CompareURLFormReaderBytes ¶
CompareURLFormReaderBytes compares the reader containing serialized URLForm document. Deserializes the URLForm documents to determine if they are equal. Return an error if the two URLForm documents are not equal.
func CompareValues ¶
func CompareValues(expect, actual interface{}, _ ...interface{}) error
CompareValues compares two values to determine if they are equal, specialized for comparison of SDK operation output types.
CompareValues expects the two values to be of the same underlying type. Doing otherwise will result in undefined behavior.
The third variadic argument is vestigial from a previous implementation that depended on go-cmp. Values passed therein have no effect.
func CompareXMLReaderBytes ¶
CompareXMLReaderBytes compares the reader with expected xml byte
func GzipCompareCompressBytes ¶ added in v1.19.0
func HasHeader ¶
HasHeader compares the header values and identifies if the actual header set includes all values specified in the expect set. Returns an error if not.
func HasHeaderKeys ¶
HasHeaderKeys validates that header set contains all keys expected. Returns an error if a header key is not in the header set.
func HasQuery ¶
HasQuery validates that the expected set of query items are present in the actual set. Returns an error if any of the expected set are not found in the actual.
func HasQueryKeys ¶
HasQueryKeys validates that the actual set of query items contains the keys provided. Returns an error if any key is not found.
func JSONEqual ¶
JSONEqual compares two JSON documents and identifies if the documents contain the same values. Returns an error if the two documents are not equal.
func NotHaveHeaderKeys ¶
NotHaveHeaderKeys validates that header set does not contains any of the keys. Returns an error if a header key is found in the header set.
func NotHaveQueryKeys ¶
NotHaveQueryKeys validates that the actual set of query items does not contain the keys provided. Returns an error if any key is found.
func URLFormEqual ¶
URLFormEqual compares two URLForm documents and identifies if the documents contain the same values. Returns an error if the two documents are not equal.
Types ¶
type ByteLoop ¶
type ByteLoop struct {
// contains filtered or unexported fields
}
ByteLoop provides an io.ReadCloser that always fills the read byte slice with repeating value, until closed.
type QueryItem ¶
QueryItem provides an escaped key and value struct for values from a raw query string.
func ParseRawQuery ¶
ParseRawQuery returns a slice of QueryItems extracted from the raw query string. The parsed QueryItems preserve escaping of key and values.
All + escape characters are replaced with %20 for consistent escaping pattern.