diff --git a/client/src/handlers/room_list_request_handler.rs b/client/src/handlers/room_list_request_handler.rs index b145f8a..c9457e2 100644 --- a/client/src/handlers/room_list_request_handler.rs +++ b/client/src/handlers/room_list_request_handler.rs @@ -50,6 +50,11 @@ mod tests { use super::RoomListRequestHandler; + // Cannot get the compiler to be satisfied when borrowing the name... + fn room_name(pair: &(String, Room)) -> String { + pair.0.clone() + } + #[test] fn run_forwards_request() { let mut bundle = ContextBundle::default(); @@ -81,14 +86,21 @@ mod tests { let response = bundle.control_response_rx.blocking_recv().unwrap(); - assert_eq!( - response, + let mut rooms = match response { control::Response::RoomListResponse(control::RoomListResponse { - rooms: vec![ - ("apple".to_string(), Room::new(Visibility::Public, 42)), - ("potato".to_string(), Room::new(Visibility::Public, 123)), - ] - }) + rooms, + }) => rooms, + _ => panic!("Unexpected control response: {:?}", response), + }; + + rooms.sort_by_key(room_name); + + assert_eq!( + rooms, + vec![ + ("apple".to_string(), Room::new(Visibility::Public, 42)), + ("potato".to_string(), Room::new(Visibility::Public, 123)), + ] ); } }