mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 12:21:18 +00:00
Add test to check reading and listing posts return my_vote (#3215)
This commit is contained in:
parent
45818fb4c5
commit
a1beccf353
1 changed files with 36 additions and 0 deletions
|
@ -746,6 +746,42 @@ mod tests {
|
|||
};
|
||||
assert_eq!(expected_post_like, inserted_post_like);
|
||||
|
||||
let post_listing_single_with_person = PostView::read(
|
||||
pool,
|
||||
data.inserted_post.id,
|
||||
Some(data.inserted_person.id),
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut expected_post_with_upvote = expected_post_view(&data, pool).await;
|
||||
expected_post_with_upvote.my_vote = Some(1);
|
||||
expected_post_with_upvote.counts.score = 1;
|
||||
expected_post_with_upvote.counts.upvotes = 1;
|
||||
assert_eq!(expected_post_with_upvote, post_listing_single_with_person);
|
||||
|
||||
let local_user_form = LocalUserUpdateForm::builder()
|
||||
.show_bot_accounts(Some(false))
|
||||
.build();
|
||||
let inserted_local_user =
|
||||
LocalUser::update(pool, data.inserted_local_user.id, &local_user_form)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let read_post_listing = PostQuery::builder()
|
||||
.pool(pool)
|
||||
.sort(Some(SortType::New))
|
||||
.community_id(Some(data.inserted_community.id))
|
||||
.local_user(Some(&inserted_local_user))
|
||||
.build()
|
||||
.list()
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(1, read_post_listing.len());
|
||||
|
||||
assert_eq!(expected_post_with_upvote, read_post_listing[0]);
|
||||
|
||||
let like_removed = PostLike::remove(pool, data.inserted_person.id, data.inserted_post.id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
Loading…
Reference in a new issue