Replace .expect() with .unwrap()

This commit is contained in:
netbrum 2024-09-30 23:00:11 +02:00
parent 23ac0c1b86
commit 986788ac3e
5 changed files with 15 additions and 38 deletions

View File

@ -69,6 +69,7 @@ impl Claims {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{claims::Claims, context::LemmyContext};
@ -94,9 +95,7 @@ mod tests {
async fn test_should_not_validate_user_token_after_password_change() -> LemmyResult<()> {
let pool_ = build_db_pool_for_tests().await;
let pool = &mut (&pool_).into();
let secret = Secret::init(pool)
.await?
.expect("Couldn't initialize secrets");
let secret = Secret::init(pool).await?.unwrap();
let context = LemmyContext::create(
pool_.clone(),
ClientBuilder::new(Client::default()).build(),

View File

@ -120,6 +120,7 @@ pub(crate) async fn get_apub_community_featured(
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
pub(crate) mod tests {
use super::*;
@ -181,9 +182,7 @@ pub(crate) mod tests {
}
async fn decode_response<T: DeserializeOwned>(res: HttpResponse) -> LemmyResult<T> {
let body = to_bytes(res.into_body())
.await
.expect("Couldn't turn response body into bytes");
let body = to_bytes(res.into_body()).await.unwrap();
let body = std::str::from_utf8(&body)?;
Ok(serde_json::from_str(body)?)
}

View File

@ -58,6 +58,7 @@ impl ReceivedActivity {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;
@ -77,9 +78,7 @@ mod tests {
// inserting activity should only work once
ReceivedActivity::create(pool, &ap_id).await?;
ReceivedActivity::create(pool, &ap_id)
.await
.expect_err("Inserting activity worked twice");
ReceivedActivity::create(pool, &ap_id).await.unwrap_err();
Ok(())
}

View File

@ -222,6 +222,7 @@ impl<T: DataSource> CommunityInboxCollector<T> {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod tests {
use super::*;
@ -333,14 +334,8 @@ mod tests {
.expect_get_instance_followed_community_inboxes()
.return_once(move |_, _| {
Ok(vec![
(
community_id,
Url::parse(url1).expect("Couldn't parse url").into(),
),
(
community_id,
Url::parse(url2).expect("Coudln't parse url").into(),
),
(community_id, Url::parse(url1).unwrap().into()),
(community_id, Url::parse(url2).unwrap().into()),
])
});
@ -437,9 +432,7 @@ mod tests {
.return_once(move |_, _| {
Ok(vec![(
community_id,
Url::parse(subdomain_inbox)
.expect("Couldn't parse url")
.into(),
Url::parse(subdomain_inbox).unwrap().into(),
)])
});
@ -493,25 +486,13 @@ mod tests {
.returning(move |_, last_fetch| {
if last_fetch == Utc.timestamp_nanos(0) {
Ok(vec![
(
community_id1,
Url::parse(user1_inbox_str)
.expect("Couldn't parse url")
.into(),
),
(
community_id2,
Url::parse(user2_inbox_str)
.expect("Couldn't parse url")
.into(),
),
(community_id1, Url::parse(user1_inbox_str).unwrap().into()),
(community_id2, Url::parse(user2_inbox_str).unwrap().into()),
])
} else {
Ok(vec![(
community_id3,
Url::parse(user3_inbox_str)
.expect("Coudln't parse url")
.into(),
Url::parse(user3_inbox_str).unwrap().into(),
)])
}
});

View File

@ -97,6 +97,7 @@ where
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;
@ -128,9 +129,7 @@ mod tests {
let pool_ = build_db_pool_for_tests().await;
let pool = &mut (&pool_).into();
let secret = Secret::init(pool)
.await?
.expect("Couldn't initialize secrets.");
let secret = Secret::init(pool).await?.unwrap();
let context = LemmyContext::create(
pool_.clone(),