mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Deflake gappy state integration test
This commit is contained in:
parent
417a47f4c5
commit
212dc34d78
@ -2,6 +2,7 @@ package syncv3
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
@ -186,7 +187,16 @@ func TestPollerHandlesUnknownStateEventsOnIncrementalSync(t *testing.T) {
|
||||
res,
|
||||
m.MatchRoomSubscription(
|
||||
roomID,
|
||||
m.MatchRoomTimeline([]json.RawMessage{nameEvent, powerLevelsEvent, messageEvent}),
|
||||
func(r sync3.Room) error {
|
||||
// syncv2 doesn't assign any meaning to the order of events in a state
|
||||
// block, so check for both possibilities
|
||||
nameFirst := m.MatchRoomTimeline([]json.RawMessage{nameEvent, powerLevelsEvent, messageEvent})
|
||||
powerLevelsFirst := m.MatchRoomTimeline([]json.RawMessage{powerLevelsEvent, nameEvent, messageEvent})
|
||||
if nameFirst(r) != nil && powerLevelsFirst(r) != nil {
|
||||
return fmt.Errorf("did not see state before message")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
m.MatchRoomName("banana"),
|
||||
),
|
||||
)
|
||||
|
@ -17,6 +17,16 @@ type ListMatcher func(list sync3.ResponseList) error
|
||||
type OpMatcher func(op sync3.ResponseOp) error
|
||||
type RoomMatcher func(r sync3.Room) error
|
||||
|
||||
// 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 LogRoom(t *testing.T) RoomMatcher {
|
||||
return func(room sync3.Room) error {
|
||||
dump, _ := json.MarshalIndent(room, "", " ")
|
||||
t.Logf("Response was: %s", dump)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func MatchRoomName(name string) RoomMatcher {
|
||||
return func(r sync3.Room) error {
|
||||
if name == "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user