mirror of https://github.com/LemmyNet/lemmy.git
fix test
parent
5fbba8a4cf
commit
807daed174
|
@ -2763,6 +2763,7 @@ dependencies = [
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"tokio",
|
"tokio",
|
||||||
"ts-rs",
|
"ts-rs",
|
||||||
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -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"]
|
||||||
|
|
|
@ -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());
|
||||||
|
|
Loading…
Reference in New Issue