mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
Add LemmyResult to federation_allowlist tests
This commit is contained in:
parent
11c534f906
commit
5fd2cbbbbc
@ -48,19 +48,19 @@ impl FederationAllowList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[expect(clippy::unwrap_used)]
|
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{federation_allowlist::FederationAllowList, instance::Instance},
|
source::{federation_allowlist::FederationAllowList, instance::Instance},
|
||||||
utils::build_db_pool_for_tests,
|
utils::build_db_pool_for_tests,
|
||||||
};
|
};
|
||||||
|
use lemmy_utils::error::LemmyResult;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_allowlist_insert_and_clear() {
|
async fn test_allowlist_insert_and_clear() -> LemmyResult<()> {
|
||||||
let pool = &build_db_pool_for_tests().await;
|
let pool = &build_db_pool_for_tests().await;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let domains = vec![
|
let domains = vec![
|
||||||
@ -71,9 +71,9 @@ mod tests {
|
|||||||
|
|
||||||
let allowed = Some(domains.clone());
|
let allowed = Some(domains.clone());
|
||||||
|
|
||||||
FederationAllowList::replace(pool, allowed).await.unwrap();
|
FederationAllowList::replace(pool, allowed).await?;
|
||||||
|
|
||||||
let allows = Instance::allowlist(pool).await.unwrap();
|
let allows = Instance::allowlist(pool).await?;
|
||||||
let allows_domains = allows
|
let allows_domains = allows
|
||||||
.iter()
|
.iter()
|
||||||
.map(|i| i.domain.clone())
|
.map(|i| i.domain.clone())
|
||||||
@ -85,13 +85,13 @@ mod tests {
|
|||||||
// Now test clearing them via Some(empty vec)
|
// Now test clearing them via Some(empty vec)
|
||||||
let clear_allows = Some(Vec::new());
|
let clear_allows = Some(Vec::new());
|
||||||
|
|
||||||
FederationAllowList::replace(pool, clear_allows)
|
FederationAllowList::replace(pool, clear_allows).await?;
|
||||||
.await
|
let allows = Instance::allowlist(pool).await?;
|
||||||
.unwrap();
|
|
||||||
let allows = Instance::allowlist(pool).await.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(0, allows.len());
|
assert_eq!(0, allows.len());
|
||||||
|
|
||||||
Instance::delete_all(pool).await.unwrap();
|
Instance::delete_all(pool).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user