lemmynsfw-changes
Felix Ableitner 2024-02-15 16:49:15 +01:00
parent 5fbba8a4cf
commit 807daed174
3 changed files with 27 additions and 2 deletions

1
Cargo.lock generated
View File

@ -2763,6 +2763,7 @@ dependencies = [
"strum_macros", "strum_macros",
"tokio", "tokio",
"ts-rs", "ts-rs",
"url",
] ]
[[package]] [[package]]

View File

@ -39,6 +39,7 @@ strum_macros = { workspace = true }
serial_test = { workspace = true } serial_test = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
pretty_assertions = { workspace = true } pretty_assertions = { workspace = true }
url.workspace = true
[package.metadata.cargo-machete] [package.metadata.cargo-machete]
ignored = ["strum"] ignored = ["strum"]

View File

@ -252,17 +252,20 @@ mod tests {
instance::Instance, instance::Instance,
local_user::{LocalUser, LocalUserInsertForm}, local_user::{LocalUser, LocalUserInsertForm},
person::{Person, PersonInsertForm}, person::{Person, PersonInsertForm},
site::Site,
}, },
traits::Crud, traits::Crud,
utils::{build_db_pool_for_tests, DbPool}, utils::{build_db_pool_for_tests, DbPool},
CommunityVisibility, CommunityVisibility,
}; };
use serial_test::serial; use serial_test::serial;
use url::Url;
struct Data { struct Data {
inserted_instance: Instance, inserted_instance: Instance,
local_user: LocalUser, local_user: LocalUser,
inserted_community: Community, inserted_community: Community,
site: Site,
} }
async fn init_data(pool: &mut DbPool<'_>) -> Data { async fn init_data(pool: &mut DbPool<'_>) -> Data {
@ -295,10 +298,30 @@ mod tests {
let inserted_community = Community::create(pool, &new_community).await.unwrap(); let inserted_community = Community::create(pool, &new_community).await.unwrap();
let url = Url::parse("http://example.com").unwrap();
let site = Site {
id: Default::default(),
name: "".to_string(),
sidebar: None,
published: Default::default(),
updated: None,
icon: None,
banner: None,
description: None,
actor_id: url.clone().into(),
last_refreshed_at: Default::default(),
inbox_url: url.into(),
private_key: None,
public_key: "".to_string(),
instance_id: Default::default(),
content_warning: None,
};
Data { Data {
inserted_instance, inserted_instance,
local_user, local_user,
inserted_community, inserted_community,
site,
} }
} }
@ -335,7 +358,7 @@ mod tests {
let unauthenticated_query = CommunityQuery { let unauthenticated_query = CommunityQuery {
..Default::default() ..Default::default()
} }
.list(pool) .list(&data.site, pool)
.await .await
.unwrap(); .unwrap();
assert_eq!(0, unauthenticated_query.len()); assert_eq!(0, unauthenticated_query.len());
@ -344,7 +367,7 @@ mod tests {
local_user: Some(&data.local_user), local_user: Some(&data.local_user),
..Default::default() ..Default::default()
} }
.list(pool) .list(&data.site, pool)
.await .await
.unwrap(); .unwrap();
assert_eq!(1, authenticated_query.len()); assert_eq!(1, authenticated_query.len());