mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-20 08:21:01 +00:00
Implement test for PostView language query
This commit is contained in:
parent
6d8494db36
commit
ec1271c423
1 changed files with 32 additions and 1 deletions
|
@ -511,6 +511,7 @@ mod tests {
|
|||
SubscribedType,
|
||||
};
|
||||
use serial_test::serial;
|
||||
use lemmy_db_schema::newtypes::LanguageIdentifier;
|
||||
|
||||
struct Data {
|
||||
inserted_person: Person,
|
||||
|
@ -561,6 +562,7 @@ mod tests {
|
|||
name: "blocked_person_post".to_string(),
|
||||
creator_id: inserted_blocked_person.id,
|
||||
community_id: inserted_community.id,
|
||||
language: Some(LanguageIdentifier::new("en")),
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
|
@ -579,6 +581,7 @@ mod tests {
|
|||
name: post_name,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
language: Some(LanguageIdentifier::new("fr")),
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
|
@ -640,7 +643,7 @@ mod tests {
|
|||
thumbnail_url: None,
|
||||
ap_id: inserted_post.ap_id.to_owned(),
|
||||
local: true,
|
||||
language: Default::default(),
|
||||
language: LanguageIdentifier::new("fr"),
|
||||
},
|
||||
my_vote: None,
|
||||
creator: PersonSafe {
|
||||
|
@ -824,4 +827,32 @@ mod tests {
|
|||
assert_eq!(1, like_removed);
|
||||
cleanup(data, &conn);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn post_listing_language() {
|
||||
let conn = establish_unpooled_connection();
|
||||
let data = init_data(&conn);
|
||||
|
||||
let mut read_post_listing_french = PostQueryBuilder::create(&conn)
|
||||
.listing_type(ListingType::Community)
|
||||
.sort(SortType::New)
|
||||
.community_id(data.inserted_community.id);
|
||||
let fr = LanguageIdentifier::new("fr");
|
||||
read_post_listing_french.languages = Some(vec![fr]);
|
||||
let read_post_listing_french = read_post_listing_french.list().unwrap();
|
||||
|
||||
let expected_post_listing = expected_post_listing(&data, &conn);
|
||||
|
||||
assert_eq!(
|
||||
1,
|
||||
read_post_listing_french.len()
|
||||
);
|
||||
assert_eq!(
|
||||
expected_post_listing,
|
||||
read_post_listing_french[0]
|
||||
);
|
||||
|
||||
cleanup(data, &conn);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue