Skip to content

Commit c8f49b4

Browse files
authored
Fix flaky user directory test
2 parents 90c47c2 + fa785c8 commit c8f49b4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tests/federation_room_join_partial_state_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3554,13 +3554,18 @@ func TestPartialStateJoin(t *testing.T) {
35543554
reqBody4 := client.WithJSONBody(t, map[string]interface{}{
35553555
"search_term": "todd",
35563556
})
3557-
res4 := rocky.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "user_directory", "search"}, reqBody4)
3558-
must.MatchResponse(t, res4, match.HTTPResponse{
3559-
StatusCode: 200,
3560-
JSON: []match.JSON{
3561-
match.JSONKeyEqual("results.0.user_id", server.UserID("todd")),
3562-
}})
3563-
3557+
rocky.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "user_directory", "search"}, reqBody4,
3558+
client.WithRetryUntil(time.Second*3, func(res *http.Response) bool {
3559+
body, err := ioutil.ReadAll(res.Body)
3560+
if err != nil {
3561+
t.Fatalf("something broke: %v", err)
3562+
}
3563+
user_id := gjson.GetBytes(body, "results.0.user_id")
3564+
if user_id.Str == server.UserID("todd") {
3565+
return true
3566+
}
3567+
return false
3568+
}))
35643569
})
35653570

35663571
// TODO: tests which assert that:

0 commit comments

Comments
 (0)