{"modulePath":"github.com/matrix-org/complement","version":"v0.0.0-20261130133012-5a6e00b89831","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package should\n\nPackage should contains assertions for tests, which returns an error if the assertion fails.\n\n## Functions\n\n```go\nfunc CheckOff(items []interface{}, wantItem interface{}) ([]interface{}, error)\n```\nEXPERIMENTAL 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.\n\n```go\nfunc CheckOffAll(items []interface{}, wantItems []interface{}) error\n```\nEXPERIMENTAL CheckOffAll checks that a list contains exactly the given items, in any order.\n\nif 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\n\n```go\nfunc CheckOffAllAllowUnwanted(items []interface{}, wantItems []interface{}) ([]interface{}, error)\n```\nEXPERIMENTAL 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.\n\nif an item is not present, an error is returned Items are compared using match.JSONDeepEqual\n\n```go\nfunc ContainSubset[V comparable](larger []V, smaller []V) error\n```\nEXPERIMENTAL 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.\n\n```go\nfunc GetJSONFieldStr(body gjson.Result, wantKey string) (string, error)\n```\nEXPERIMENTAL 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](https://godoc.org/github.com/tidwall/gjson#Get)\n\n```go\nfunc GetTimelineEventIDs(topLevelSyncJSON gjson.Result, roomID string) []string\n```\nEXPERIMENTAL 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.\n\n```go\nfunc HaveInOrder[V comparable](gots []V, wants []V) error\n```\nEXPERIMENTAL HaveInOrder checks that the two slices match exactly, failing the test on mismatches or omissions.\n\n```go\nfunc MatchFailure(res *http.Response) error\n```\nEXPERIMENTAL MatchFailure consumes the HTTP response and fails if the response is 2xx.\n\n```go\nfunc MatchFederationRequest(fedReq *fclient.FederationRequest, matchers ...match.JSON) error\n```\nMatchFederationRequest performs JSON assertions on incoming federation requests.\n\n```go\nfunc MatchGJSON(jsonResult gjson.Result, matchers ...match.JSON) error\n```\nEXPERIMENTAL MatchGJSON performs JSON assertions on a gjson.Result object.\n\n```go\nfunc MatchJSONBytes(rawJson []byte, matchers ...match.JSON) error\n```\nEXPERIMENTAL MatchJSONBytes performs JSON assertions on a raw json byte slice.\n\n```go\nfunc MatchRequest(req *http.Request, m match.HTTPRequest) ([]byte, error)\n```\nEXPERIMENTAL MatchRequest consumes the HTTP request and performs HTTP-level assertions on it. Returns the raw response body.\n\n```go\nfunc MatchResponse(res *http.Response, m match.HTTPResponse) ([]byte, error)\n```\nEXPERIMENTAL MatchResponse consumes the HTTP response and performs HTTP-level assertions on it. Returns the raw response body.\n\n```go\nfunc MatchSuccess(res *http.Response) error\n```\nEXPERIMENTAL MatchSuccess consumes the HTTP response and fails if the response is non-2xx.\n\n```go\nfunc NotContainSubset[V comparable](larger []V, smaller []V) error\n```\nEXPERIMENTAL 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.\n\n```go\nfunc ParseJSON(b io.ReadCloser) (res gjson.Result, err error)\n```\nEXPERIMENTAL ParseJSON will ensure that the HTTP request/response body is valid JSON, then return the body, else returns an error.\n\n","path":"github.com/matrix-org/complement/should","name":"should","synopsis":"Package should contains assertions for tests, which returns an error if the assertion fails.","isRedistributable":true}
