mirror of
https://github.com/chatmail/core.git
synced 2026-04-25 01:16:29 +03:00
resultify get_fresh_msgs(), this will make eg. test fail on bad sql
This commit is contained in:
@@ -431,8 +431,9 @@ impl Context {
|
||||
/// and is typically used to show notifications.
|
||||
/// Moreover, the number of returned messages
|
||||
/// can be used for a badge counter on the app icon.
|
||||
pub async fn get_fresh_msgs(&self) -> Vec<MsgId> {
|
||||
self.sql
|
||||
pub async fn get_fresh_msgs(&self) -> Result<Vec<MsgId>> {
|
||||
let ret = self
|
||||
.sql
|
||||
.query_map(
|
||||
concat!(
|
||||
"SELECT m.id",
|
||||
@@ -459,8 +460,8 @@ impl Context {
|
||||
Ok(ret)
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.await?;
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
/// Searches for messages containing the query string.
|
||||
@@ -610,7 +611,7 @@ mod tests {
|
||||
#[async_std::test]
|
||||
async fn test_get_fresh_msgs() {
|
||||
let t = TestContext::new().await;
|
||||
let fresh = t.get_fresh_msgs().await;
|
||||
let fresh = t.get_fresh_msgs().await.unwrap();
|
||||
assert!(fresh.is_empty())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user