Skip to content

Commit 796eaa9

Browse files
committed
Better failure when expected event but none returned
1 parent 11bea9a commit 796eaa9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/msc3030_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,14 @@ func mustCheckEventisReturnedForTime(t *testing.T, c *client.CSAPI, roomID strin
306306
}))
307307
timestampToEventResBody := client.ParseJSON(t, timestampToEventRes)
308308

309-
// Only allow a 200 response meaning we found an event or a 404 meaning we didn't.
310-
// Other status codes will throw and assumed to be application errors.
309+
// Only allow a 200 response meaning we found an event or when no `expectedEventId`, a
310+
// 404 meaning we didn't find anything. Other status codes will throw and assumed to
311+
// be application errors.
311312
actualEventId := ""
312313
if timestampToEventRes.StatusCode == 200 {
313314
actualEventId = client.GetJSONFieldStr(t, timestampToEventResBody, "event_id")
314-
} else if timestampToEventRes.StatusCode != 404 {
315-
t.Fatalf("mustCheckEventisReturnedForTime: /timestamp_to_event request failed with status=%d", timestampToEventRes.StatusCode)
315+
} else if timestampToEventRes.StatusCode != 404 || (timestampToEventRes.StatusCode == 404 && expectedEventId != "") {
316+
t.Fatalf("mustCheckEventisReturnedForTime: /timestamp_to_event request failed with status=%d body=%s", timestampToEventRes.StatusCode, string(timestampToEventResBody))
316317
}
317318

318319
if actualEventId != expectedEventId {

0 commit comments

Comments
 (0)