Documentation ¶
Overview ¶
Package must contains assertions for tests, which fail the test if the assertion fails.
Index ¶
- func CheckOff(t ct.TestLike, items []interface{}, wantItem interface{}) []interface{}
- func CheckOffAll(t ct.TestLike, items []interface{}, wantItems []interface{})
- func CheckOffAllAllowUnwanted(t ct.TestLike, items []interface{}, wantItems []interface{}) []interface{}
- func ContainSubset[V comparable](t ct.TestLike, larger []V, smaller []V)
- func Equal[V comparable](t ct.TestLike, got, want V, msg string)
- func GetJSONFieldStr(t ct.TestLike, body gjson.Result, wantKey string) string
- func HaveInOrder[V comparable](t ct.TestLike, gots []V, wants []V)
- func MatchFailure(t ct.TestLike, res *http.Response)
- func MatchFederationRequest(t ct.TestLike, fedReq *fclient.FederationRequest, matchers ...match.JSON)
- func MatchGJSON(t ct.TestLike, jsonResult gjson.Result, matchers ...match.JSON)
- func MatchJSONBytes(t ct.TestLike, rawJson []byte, matchers ...match.JSON)
- func MatchRequest(t ct.TestLike, req *http.Request, m match.HTTPRequest) []byte
- func MatchResponse(t ct.TestLike, res *http.Response, m match.HTTPResponse) []byte
- func MatchSuccess(t ct.TestLike, res *http.Response)
- func NotContainSubset[V comparable](t ct.TestLike, larger []V, smaller []V)
- func NotEqual[V comparable](t ct.TestLike, got, want V, msg string)
- func NotError(t ct.TestLike, msg string, err error)
- func ParseJSON(t ct.TestLike, b io.ReadCloser) gjson.Result
- func StartWithStr(t ct.TestLike, got, wantPrefix, msg string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckOff ¶
EXPERIMENTAL CheckOff an item from the list. If the item is not present the test is failed. The updated list with the matched item removed from it is returned. Items are compared using JSON deep equal.
func CheckOffAll ¶
EXPERIMENTAL CheckOffAll checks that a list contains exactly the given items, in any order.
if an item is not present, the test is failed. if an item not present in the want list is present, the test is failed. Items are compared using match.JSONDeepEqual
func CheckOffAllAllowUnwanted ¶
func CheckOffAllAllowUnwanted(t ct.TestLike, items []interface{}, wantItems []interface{}) []interface{}
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, the test is failed. Items are compared using match.JSONDeepEqual
func ContainSubset ¶
func ContainSubset[V comparable](t ct.TestLike, larger []V, smaller []V)
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 Equal ¶
func Equal[V comparable](t ct.TestLike, got, want V, msg string)
Equal ensures that got==want else logs an error. The 'msg' is displayed with the error to provide extra context.
func GetJSONFieldStr ¶
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 HaveInOrder ¶
func HaveInOrder[V comparable](t ct.TestLike, gots []V, wants []V)
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(t ct.TestLike, fedReq *fclient.FederationRequest, matchers ...match.JSON)
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](t ct.TestLike, larger []V, smaller []V)
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.
func NotEqual ¶
func NotEqual[V comparable](t ct.TestLike, got, want V, msg string)
NotEqual ensures that got!=want else logs an error. The 'msg' is displayed with the error to provide extra context.
func ParseJSON ¶
EXPERIMENTAL ParseJSON will ensure that the HTTP request/response body is valid JSON, then return the body, else terminate the test.
func StartWithStr ¶
EXPERIMENTAL StartWithStr ensures that got starts with wantPrefix else logs an error.
Types ¶
This section is empty.