nit: prefer using assert_matches! in tests

This commit is contained in:
Benjamin Bouvier
2023-08-04 17:19:23 +02:00
parent dd3cab9409
commit 5c74a597eb
2 changed files with 9 additions and 10 deletions

View File

@@ -415,6 +415,7 @@ impl NotificationClient {
}
}
#[derive(Debug)]
pub enum NotificationStatus {
Event(NotificationItem),
EventNotFound,

View File

@@ -76,11 +76,10 @@ async fn test_notification() -> Result<()> {
// Try with sliding sync first.
let notification_client = NotificationClient::builder(bob.clone()).await.unwrap().build();
let NotificationStatus::Event(notification) =
notification_client.get_notification_with_sliding_sync(&room_id, &event_id).await?
else {
panic!("event not found");
};
let notification = assert_matches!(
notification_client.get_notification_with_sliding_sync(&room_id, &event_id).await?,
NotificationStatus::Event(event) => event
);
warn!("sliding_sync: checking invite notification");
@@ -191,11 +190,10 @@ async fn test_notification() -> Result<()> {
};
let notification_client = NotificationClient::builder(bob.clone()).await.unwrap().build();
let NotificationStatus::Event(notification) =
notification_client.get_notification_with_sliding_sync(&room_id, &event_id).await?
else {
panic!("event not found");
};
let notification = assert_matches!(
notification_client.get_notification_with_sliding_sync(&room_id, &event_id).await?,
NotificationStatus::Event(item) => item
);
check_notification(true, notification);
let notification_client = NotificationClient::builder(bob.clone()).await.unwrap().build();