Documentation ¶
Overview ¶
Package should contains assertions for tests, which returns an error if the assertion fails.
Index ¶
- func CheckOff(items []interface{}, wantItem interface{}) ([]interface{}, error)
- func CheckOffAll(items []interface{}, wantItems []interface{}) error
- func CheckOffAllAllowUnwanted(items []interface{}, wantItems []interface{}) ([]interface{}, error)
- func ContainSubset[V comparable](larger []V, smaller []V) error
- func GetJSONFieldStr(body gjson.Result, wantKey string) (string, error)
- func GetTimelineEventIDs(topLevelSyncJSON gjson.Result, roomID string) []string
- func HaveInOrder[V comparable](gots []V, wants []V) error
- func MatchFailure(res *http.Response) error
- func MatchFederationRequest(fedReq *fclient.FederationRequest, matchers ...match.JSON) error
- func MatchGJSON(jsonResult gjson.Result, matchers ...match.JSON) error
- func MatchJSONBytes(rawJson []byte, matchers ...match.JSON) error
- func MatchRequest(req *http.Request, m match.HTTPRequest) ([]byte, error)
- func MatchResponse(res *http.Response, m match.HTTPResponse) ([]byte, error)
- func MatchSuccess(res *http.Response) error
- func NotContainSubset[V comparable](larger []V, smaller []V) error
- func ParseJSON(b io.ReadCloser) (res gjson.Result, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckOff ¶
func CheckOff(items []interface{}, wantItem interface{}) ([]interface{}, error)
EXPERIMENTAL CheckOff an item from the list. If the item is not present an error is returned The updated list with the matched item removed from it is returned. Items are compared using JSON deep equal.
func CheckOffAll ¶
func CheckOffAll(items []interface{}, wantItems []interface{}) error
EXPERIMENTAL CheckOffAll checks that a list contains exactly the given items, in any order.
if an item is not present, an error is returned. if an item not present in the want list is present, an error is returned. Items are compared using match.JSONDeepEqual
func CheckOffAllAllowUnwanted ¶
func CheckOffAllAllowUnwanted(items []interface{}, wantItems []interface{}) ([]interface{}, error)
EXPERIMENTAL CheckOffAllAllowUnwanted checks that a list contains all of the given items, in any order. The updated list with the matched items removed from it is returned.
if an item is not present, an error is returned Items are compared using match.JSONDeepEqual
func ContainSubset ¶
func ContainSubset[V comparable](larger []V, smaller []V) error
EXPERIMENTAL ContainSubset checks that every item in smaller is in larger, failing the test if at least 1 item isn't. Ignores extra elements in larger. Ignores ordering.
func GetJSONFieldStr ¶
EXPERIMENTAL GetJSONFieldStr extracts the string value under `wantKey` or fails the test. The format of `wantKey` is specified at https://godoc.org/github.com/tidwall/gjson#Get
func GetTimelineEventIDs ¶
EXPERIMENTAL GetTimelineEventIDs returns the timeline event IDs in the sync response for the given room ID. If the room is missing this returns a 0 element slice.
func HaveInOrder ¶
func HaveInOrder[V comparable](gots []V, wants []V) error
EXPERIMENTAL HaveInOrder checks that the two slices match exactly, failing the test on mismatches or omissions.
func MatchFailure ¶
EXPERIMENTAL MatchFailure consumes the HTTP response and fails if the response is 2xx.
func MatchFederationRequest ¶
func MatchFederationRequest(fedReq *fclient.FederationRequest, matchers ...match.JSON) error
MatchFederationRequest performs JSON assertions on incoming federation requests.
func MatchGJSON ¶
EXPERIMENTAL MatchGJSON performs JSON assertions on a gjson.Result object.
func MatchJSONBytes ¶
EXPERIMENTAL MatchJSONBytes performs JSON assertions on a raw json byte slice.
func MatchRequest ¶
EXPERIMENTAL MatchRequest consumes the HTTP request and performs HTTP-level assertions on it. Returns the raw response body.
func MatchResponse ¶
EXPERIMENTAL MatchResponse consumes the HTTP response and performs HTTP-level assertions on it. Returns the raw response body.
func MatchSuccess ¶
EXPERIMENTAL MatchSuccess consumes the HTTP response and fails if the response is non-2xx.
func NotContainSubset ¶
func NotContainSubset[V comparable](larger []V, smaller []V) error
EXPERIMENTAL NotContainSubset checks that every item in smaller is NOT in larger, failing the test if at least 1 item is. Ignores extra elements in larger. Ignores ordering.
Types ¶
This section is empty.