Documentation ¶
Index ¶
- Constants
- func CheckList(listKey string, res sync3.ResponseList, matchers ...ListMatcher) error
- func CheckRoom(r sync3.Room, matchers ...RoomMatcher) error
- func EqualAnyOrder(got, want []json.RawMessage) error
- func MatchResponse(t *testing.T, res *sync3.Response, matchers ...RespMatcher)
- type ListMatcher
- type OpMatcher
- func MatchV3DeleteOp(roomIndex int) OpMatcher
- func MatchV3InsertOp(roomIndex int, roomID string) OpMatcher
- func MatchV3InvalidateOp(start, end int64) OpMatcher
- func MatchV3SyncOp(start, end int64, roomIDs []string, anyOrder ...bool) OpMatcher
- func MatchV3SyncOpFn(fn func(op *sync3.ResponseOpRange) error) OpMatcher
- type Receipt
- type RespMatcher
- func LogResponse(t *testing.T) RespMatcher
- func LogRooms(t *testing.T) RespMatcher
- func MatchAccountData(globals []json.RawMessage, rooms map[string][]json.RawMessage) RespMatcher
- func MatchDeviceLists(changed, left []string) RespMatcher
- func MatchFallbackKeyTypes(fallbackKeyTypes []string) RespMatcher
- func MatchHasGlobalAccountData(want json.RawMessage) RespMatcher
- func MatchList(listKey string, matchers ...ListMatcher) RespMatcher
- func MatchLists(matchers map[string][]ListMatcher) RespMatcher
- func MatchNoE2EEExtension() RespMatcher
- func MatchNoGlobalAccountData() RespMatcher
- func MatchNoReceiptsExtension() RespMatcher
- func MatchNoRoomAccountData(roomIDs []string) RespMatcher
- func MatchNoV3Ops() RespMatcher
- func MatchNotTyping(roomID string, dontWantUserIDs []string) RespMatcher
- func MatchOTKCounts(otkCounts map[string]int) RespMatcher
- func MatchReceipts(roomID string, wantReceipts []Receipt) RespMatcher
- func MatchRoomSubscription(roomID string, matchers ...RoomMatcher) RespMatcher
- func MatchRoomSubscriptions(wantSubs map[string][]RoomMatcher) RespMatcher
- func MatchRoomSubscriptionsStrict(wantSubs map[string][]RoomMatcher) RespMatcher
- func MatchToDeviceMessages(wantMsgs []json.RawMessage) RespMatcher
- func MatchTxnID(txnID string) RespMatcher
- func MatchTyping(roomID string, wantUserIDs []string) RespMatcher
- type RoomMatcher
- func LogRoom(t *testing.T) RoomMatcher
- func MatchInviteCount(count int) RoomMatcher
- func MatchJoinCount(count int) RoomMatcher
- func MatchNoInviteCount() RoomMatcher
- func MatchNumLive(numLive int) RoomMatcher
- func MatchRoomAvatar(wantAvatar string) RoomMatcher
- func MatchRoomHasInviteState() RoomMatcher
- func MatchRoomHighlightCount(count int64) RoomMatcher
- func MatchRoomInitial(initial bool) RoomMatcher
- func MatchRoomInviteState(events []json.RawMessage) RoomMatcher
- func MatchRoomIsDM(wantDM bool) RoomMatcher
- func MatchRoomLacksInviteState() RoomMatcher
- func MatchRoomName(name string) RoomMatcher
- func MatchRoomNotificationCount(count int64) RoomMatcher
- func MatchRoomPrevBatch(prevBatch string) RoomMatcher
- func MatchRoomRequiredState(events []json.RawMessage) RoomMatcher
- func MatchRoomTimeline(events []json.RawMessage) RoomMatcher
- func MatchRoomTimelineMostRecent(n int, events []json.RawMessage) RoomMatcher
- func MatchRoomUnchangedAvatar() RoomMatcher
- func MatchRoomUnsetAvatar() RoomMatcher
Constants ¶
const AnsiRedForeground = "\x1b[31m"
const AnsiResetForeground = "\x1b[39m"
Variables ¶
This section is empty.
Functions ¶
func CheckList ¶
func CheckList(listKey string, res sync3.ResponseList, matchers ...ListMatcher) error
func EqualAnyOrder ¶
func EqualAnyOrder(got, want []json.RawMessage) error
func MatchResponse ¶
func MatchResponse(t *testing.T, res *sync3.Response, matchers ...RespMatcher)
Types ¶
type ListMatcher ¶
type ListMatcher func(list sync3.ResponseList) error
func MatchV3Count ¶
func MatchV3Count(wantCount int) ListMatcher
func MatchV3Ops ¶
func MatchV3Ops(matchOps ...OpMatcher) ListMatcher
type OpMatcher ¶
type OpMatcher func(op sync3.ResponseOp) error
func MatchV3DeleteOp ¶
func MatchV3InsertOp ¶
func MatchV3InvalidateOp ¶
func MatchV3SyncOp ¶
func MatchV3SyncOpFn ¶
func MatchV3SyncOpFn(fn func(op *sync3.ResponseOpRange) error) OpMatcher
type RespMatcher ¶
func LogResponse ¶ added in v0.99.2
func LogResponse(t *testing.T) RespMatcher
LogResponse builds a matcher that always succeeds. As a side-effect, it pretty-prints the given sync response to the test log. This is useful when debugging a test.
func LogRooms ¶ added in v0.99.5
func LogRooms(t *testing.T) RespMatcher
LogRooms is like LogResponse, but only logs the rooms section of the response.
func MatchAccountData ¶
func MatchAccountData(globals []json.RawMessage, rooms map[string][]json.RawMessage) RespMatcher
MatchAccountData builds a matcher which asserts that the account data in a sync response /exactly/ matches the given `globals` and `rooms`, up to ordering.
- If there is no account data extension in the response, the matche fails. - If globals is non-nil:
- if globals is not equal to the global account data, the match fails. Equality is determined using EqualAnyOrder.
- If rooms is non-nil:
- If the set of given rooms differs from the set of rooms present in the account data response, the match fails.
- If a given room's account data events are not equal to its account data events in the sync response, the match fails. Again, equality is determined using EqualAnyOrder.
func MatchDeviceLists ¶
func MatchDeviceLists(changed, left []string) RespMatcher
func MatchFallbackKeyTypes ¶
func MatchFallbackKeyTypes(fallbackKeyTypes []string) RespMatcher
func MatchHasGlobalAccountData ¶ added in v0.99.2
func MatchHasGlobalAccountData(want json.RawMessage) RespMatcher
MatchHasGlobalAccountData builds a matcher which asserts that the given event is present in a global account data response.
func MatchList ¶
func MatchList(listKey string, matchers ...ListMatcher) RespMatcher
func MatchLists ¶
func MatchLists(matchers map[string][]ListMatcher) RespMatcher
func MatchNoE2EEExtension ¶ added in v0.98.1
func MatchNoE2EEExtension() RespMatcher
func MatchNoGlobalAccountData ¶ added in v0.99.2
func MatchNoGlobalAccountData() RespMatcher
MatchNoGlobalAccountData builds a matcher which asserts that no global account data is present in a sync response.
func MatchNoReceiptsExtension ¶ added in v0.99.1
func MatchNoReceiptsExtension() RespMatcher
func MatchNoRoomAccountData ¶ added in v0.99.2
func MatchNoRoomAccountData(roomIDs []string) RespMatcher
MatchNoRoomAccountData builds a matcher which asserts that none of the given roomIDs have room account data in a sync response.
func MatchNoV3Ops ¶
func MatchNoV3Ops() RespMatcher
func MatchNotTyping ¶ added in v0.99.2
func MatchNotTyping(roomID string, dontWantUserIDs []string) RespMatcher
func MatchOTKCounts ¶
func MatchOTKCounts(otkCounts map[string]int) RespMatcher
func MatchReceipts ¶
func MatchReceipts(roomID string, wantReceipts []Receipt) RespMatcher
MatchReceipts builds a matcher which asserts that a sync response has the expected set of read receipts in a given room is the expected set of `wantReceipts`.
The match fails if:
- there is no receipts extension in the sync response,
- the room is missing from the sync response and `wantReceipts` is nonempty,
- the room is present in the sync response but has a different set of receipts to `wantReceipts`.
func MatchRoomSubscription ¶
func MatchRoomSubscription(roomID string, matchers ...RoomMatcher) RespMatcher
func MatchRoomSubscriptions ¶
func MatchRoomSubscriptions(wantSubs map[string][]RoomMatcher) RespMatcher
func MatchRoomSubscriptionsStrict ¶
func MatchRoomSubscriptionsStrict(wantSubs map[string][]RoomMatcher) RespMatcher
func MatchToDeviceMessages ¶
func MatchToDeviceMessages(wantMsgs []json.RawMessage) RespMatcher
func MatchTxnID ¶
func MatchTxnID(txnID string) RespMatcher
func MatchTyping ¶
func MatchTyping(roomID string, wantUserIDs []string) RespMatcher
type RoomMatcher ¶
func LogRoom ¶ added in v0.99.3
func LogRoom(t *testing.T) RoomMatcher
LogRoom builds a matcher that always succeeds. As a side-effect, it pretty-prints the given room to the test log. This is useful when debugging a test.
func MatchInviteCount ¶
func MatchInviteCount(count int) RoomMatcher
func MatchJoinCount ¶
func MatchJoinCount(count int) RoomMatcher
func MatchNoInviteCount ¶ added in v0.99.4
func MatchNoInviteCount() RoomMatcher
func MatchNumLive ¶
func MatchNumLive(numLive int) RoomMatcher
func MatchRoomAvatar ¶ added in v0.99.5
func MatchRoomAvatar(wantAvatar string) RoomMatcher
MatchRoomAvatar builds a RoomMatcher which checks that the given room response has set the room's avatar to the given value.
func MatchRoomHasInviteState ¶ added in v0.99.12
func MatchRoomHasInviteState() RoomMatcher
func MatchRoomHighlightCount ¶
func MatchRoomHighlightCount(count int64) RoomMatcher
func MatchRoomInitial ¶
func MatchRoomInitial(initial bool) RoomMatcher
func MatchRoomInviteState ¶
func MatchRoomInviteState(events []json.RawMessage) RoomMatcher
func MatchRoomIsDM ¶ added in v0.99.15
func MatchRoomIsDM(wantDM bool) RoomMatcher
func MatchRoomLacksInviteState ¶ added in v0.99.12
func MatchRoomLacksInviteState() RoomMatcher
func MatchRoomName ¶
func MatchRoomName(name string) RoomMatcher
func MatchRoomNotificationCount ¶
func MatchRoomNotificationCount(count int64) RoomMatcher
func MatchRoomPrevBatch ¶
func MatchRoomPrevBatch(prevBatch string) RoomMatcher
func MatchRoomRequiredState ¶
func MatchRoomRequiredState(events []json.RawMessage) RoomMatcher
func MatchRoomTimeline ¶
func MatchRoomTimeline(events []json.RawMessage) RoomMatcher
Match the timeline with exactly these events in exactly this order
func MatchRoomTimelineMostRecent ¶
func MatchRoomTimelineMostRecent(n int, events []json.RawMessage) RoomMatcher
Similar to MatchRoomTimeline but takes the last n events of `events` and only checks with the last n events of the timeline.
func MatchRoomUnchangedAvatar ¶ added in v0.99.5
func MatchRoomUnchangedAvatar() RoomMatcher
MatchRoomUnchangedAvatar builds a RoomMatcher which checks that the given room has no change to its avatar, or has had its avatar deleted.
func MatchRoomUnsetAvatar ¶ added in v0.99.5
func MatchRoomUnsetAvatar() RoomMatcher
MatchRoomUnsetAvatar builds a RoomMatcher which checks that the given room has no avatar, or has had its avatar deleted.