Skip to content

Commit 279d1b3

Browse files
committed
Don't test order of delayed events in GET response
as the MSC does not (yet) specify an order for them
1 parent 6f86880 commit 279d1b3

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

tests/msc4140/delayed_event_test.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,11 @@ func TestDelayedEvents(t *testing.T) {
8787
})
8888
}
8989

90-
checkContent := func(val gjson.Result) error {
91-
content := val.Get("content").Map()
92-
if l := len(content); l != 1 {
93-
return fmt.Errorf("wrong number of content fields: expected 1, got %d", l)
94-
}
95-
countExpected++
96-
if countActual := content[countKey].Uint(); countActual != countExpected {
97-
return fmt.Errorf("wrong count in delayed event content: expected %v, got %v", countExpected, countActual)
98-
}
99-
return nil
100-
}
101-
10290
res = getDelayedEvents(t, user)
10391
countExpected = 0
10492
must.MatchResponse(t, res, match.HTTPResponse{
10593
JSON: []match.JSON{
10694
match.JSONKeyArrayOfSize("delayed_events", numEvents),
107-
match.JSONArrayEach("delayed_events", checkContent),
10895
},
10996
})
11097

@@ -131,7 +118,17 @@ func TestDelayedEvents(t *testing.T) {
131118
countExpected = 0
132119
must.MatchResponse(t, res, match.HTTPResponse{
133120
JSON: []match.JSON{
134-
match.JSONArrayEach("chunk", checkContent),
121+
match.JSONArrayEach("chunk", func(val gjson.Result) error {
122+
content := val.Get("content").Map()
123+
if l := len(content); l != 1 {
124+
return fmt.Errorf("wrong number of content fields: expected 1, got %d", l)
125+
}
126+
countExpected++
127+
if countActual := content[countKey].Uint(); countActual != countExpected {
128+
return fmt.Errorf("wrong count in delayed event content: expected %v, got %v", countExpected, countActual)
129+
}
130+
return nil
131+
}),
135132
},
136133
})
137134
})

0 commit comments

Comments
 (0)