Skip to content

Commit 96d0a03

Browse files
committed
Be tolerant of the the end key not existing in a /messages resposne
Split out from #214
1 parent 0b7d990 commit 96d0a03

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/msc2716_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,6 @@ func paginateUntilMessageCheckOff(t *testing.T, c *client.CSAPI, roomID string,
12541254
}))
12551255
callCounter++
12561256
messsageResBody := client.ParseJSON(t, messagesRes)
1257-
messageResEnd = client.GetJSONFieldStr(t, messsageResBody, "end")
12581257
// Since the original body can only be read once, create a new one from the body bytes we just read
12591258
messagesRes.Body = ioutil.NopCloser(bytes.NewBuffer(messsageResBody))
12601259

@@ -1294,6 +1293,12 @@ func paginateUntilMessageCheckOff(t *testing.T, c *client.CSAPI, roomID string,
12941293
if len(workingExpectedEventIDMap) == 0 {
12951294
return
12961295
}
1296+
1297+
// Since this will throw an error if they key does not exist, do this at the end of
1298+
// the loop. It's a valid scenario to be at the end of the room and have no more to
1299+
// paginate so we want to make sure the `return` above runs when we've found all of
1300+
// the expected events.
1301+
messageResEnd = client.GetJSONFieldStr(t, messsageResBody, "end")
12971302
}
12981303
}
12991304

0 commit comments

Comments
 (0)