Skip to content

Commit

Permalink
Be tolerant of the the end key not existing in a /messages resposne
Browse files Browse the repository at this point in the history
Split out from #214
  • Loading branch information
MadLittleMods committed Oct 4, 2022
1 parent 0b7d990 commit 96d0a03
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/msc2716_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,6 @@ func paginateUntilMessageCheckOff(t *testing.T, c *client.CSAPI, roomID string,
}))
callCounter++
messsageResBody := client.ParseJSON(t, messagesRes)
messageResEnd = client.GetJSONFieldStr(t, messsageResBody, "end")
// Since the original body can only be read once, create a new one from the body bytes we just read
messagesRes.Body = ioutil.NopCloser(bytes.NewBuffer(messsageResBody))

Expand Down Expand Up @@ -1294,6 +1293,12 @@ func paginateUntilMessageCheckOff(t *testing.T, c *client.CSAPI, roomID string,
if len(workingExpectedEventIDMap) == 0 {
return
}

// Since this will throw an error if they key does not exist, do this at the end of
// the loop. It's a valid scenario to be at the end of the room and have no more to
// paginate so we want to make sure the `return` above runs when we've found all of
// the expected events.
messageResEnd = client.GetJSONFieldStr(t, messsageResBody, "end")
}
}

Expand Down

0 comments on commit 96d0a03

Please sign in to comment.