@@ -97,13 +97,9 @@ impl MatrixMockServer {
9797 /// Overrides the sync/ endpoint with knowledge that the given
9898 /// invited/joined/knocked/left room exists, runs a sync and returns the
9999 /// given room.
100- pub async fn sync_room (
101- & self ,
102- client : & Client ,
103- room_id : & RoomId ,
104- room_data : impl Into < AnyRoomBuilder > ,
105- ) -> Room {
100+ pub async fn sync_room ( & self , client : & Client , room_data : impl Into < AnyRoomBuilder > ) -> Room {
106101 let any_room = room_data. into ( ) ;
102+ let room_id = any_room. room_id ( ) . to_owned ( ) ;
107103
108104 self . mock_sync ( )
109105 . ok_and_run ( client, move |builder| match any_room {
@@ -122,13 +118,13 @@ impl MatrixMockServer {
122118 } )
123119 . await ;
124120
125- client. get_room ( room_id) . expect ( "look at me, the room is known now" )
121+ client. get_room ( & room_id) . expect ( "look at me, the room is known now" )
126122 }
127123
128124 /// Overrides the sync/ endpoint with knowledge that the given room exists
129125 /// in the joined state, runs a sync and returns the given room.
130126 pub async fn sync_joined_room ( & self , client : & Client , room_id : & RoomId ) -> Room {
131- self . sync_room ( client, room_id , JoinedRoomBuilder :: new ( room_id) ) . await
127+ self . sync_room ( client, JoinedRoomBuilder :: new ( room_id) ) . await
132128 }
133129
134130 /// Verify that the previous mocks expected number of requests match
@@ -236,6 +232,18 @@ pub enum AnyRoomBuilder {
236232 Knocked ( KnockedRoomBuilder ) ,
237233}
238234
235+ impl AnyRoomBuilder {
236+ /// Get the [`RoomId`] of the room this [`AnyRoomBuilder`] will create.
237+ fn room_id ( & self ) -> & RoomId {
238+ match self {
239+ AnyRoomBuilder :: Invited ( r) => r. room_id ( ) ,
240+ AnyRoomBuilder :: Joined ( r) => r. room_id ( ) ,
241+ AnyRoomBuilder :: Left ( r) => r. room_id ( ) ,
242+ AnyRoomBuilder :: Knocked ( r) => r. room_id ( ) ,
243+ }
244+ }
245+ }
246+
239247impl From < InvitedRoomBuilder > for AnyRoomBuilder {
240248 fn from ( val : InvitedRoomBuilder ) -> AnyRoomBuilder {
241249 AnyRoomBuilder :: Invited ( val)
0 commit comments