@@ -14,6 +14,8 @@ import (
1414 "testing"
1515 "time"
1616
17+ "net/http"
18+
1719 "github.com/matrix-org/gomatrixserverlib"
1820 "github.com/tidwall/gjson"
1921
@@ -433,39 +435,37 @@ func publishAndCheckRoomJoinRule(t *testing.T, c *client.CSAPI, roomID, expected
433435 )
434436
435437 // Check that we can see the room in the directory
436- res := c .MustDo (
437- t ,
438- "GET" ,
439- []string {"_matrix" , "client" , "v3" , "publicRooms" },
440- nil ,
441- )
442-
443- roomFound := false
444- must .MatchResponse (t , res , match.HTTPResponse {
445- JSON : []match.JSON {
446- // For each public room directory chunk (representing a single room entry)
447- match .JSONArrayEach ("chunk" , func (r gjson.Result ) error {
448- // If this is our room
449- if r .Get ("room_id" ).Str == roomID {
450- roomFound = true
451-
452- // Check that the join_rule key exists and is as we expect
453- if roomJoinRule := r .Get ("join_rule" ).Str ; roomJoinRule != expectedJoinRule {
454- return fmt .Errorf (
455- "'join_rule' key for room in public room chunk is '%s', expected '%s'" ,
456- roomJoinRule , expectedJoinRule ,
457- )
458- }
459- }
460- return nil
461- }),
462- },
463- })
438+ c .MustDoFunc (t , "GET" , []string {"_matrix" , "client" , "v3" , "publicRooms" },
439+ client .WithRetryUntil (time .Second , func (res * http.Response ) bool {
440+ roomFound := false
441+ must .MatchResponse (t , res , match.HTTPResponse {
442+ JSON : []match.JSON {
443+ // For each public room directory chunk (representing a single room entry)
444+ match .JSONArrayEach ("chunk" , func (r gjson.Result ) error {
445+ // If this is our room
446+ if r .Get ("room_id" ).Str == roomID {
447+ roomFound = true
448+
449+ // Check that the join_rule key exists and is as we expect
450+ if roomJoinRule := r .Get ("join_rule" ).Str ; roomJoinRule != expectedJoinRule {
451+ return fmt .Errorf (
452+ "'join_rule' key for room in public room chunk is '%s', expected '%s'" ,
453+ roomJoinRule , expectedJoinRule ,
454+ )
455+ }
456+ }
457+ return nil
458+ }),
459+ },
460+ })
464461
465- // Check that we did in fact see the room
466- if ! roomFound {
467- t .Fatalf ("Room was not present in public room directory response" )
468- }
462+ // Check that we did in fact see the room
463+ if ! roomFound {
464+ t .Logf ("Room was not present in public room directory response" )
465+ }
466+ return roomFound
467+ }),
468+ )
469469}
470470
471471// TestCannotSendNonKnockViaSendKnock checks that we cannot submit anything via /send_knock except a knock
0 commit comments