X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_schema%2Fsrc%2Faggregates%2Fperson_aggregates.rs;h=295f1bfbb94f78947aea0883c86ef711b70d7156;hb=bbca6ef6dcad4e569fc868947e48e004f60ef43d;hp=6f804590845016db79490b97d44e6c8932ecb309;hpb=696cca4ce447445d863717d61300f1ffb3ab4d4c;p=lemmy.git diff --git a/crates/db_schema/src/aggregates/person_aggregates.rs b/crates/db_schema/src/aggregates/person_aggregates.rs index 6f804590..295f1bfb 100644 --- a/crates/db_schema/src/aggregates/person_aggregates.rs +++ b/crates/db_schema/src/aggregates/person_aggregates.rs @@ -22,7 +22,7 @@ mod tests { use crate::{ aggregates::person_aggregates::PersonAggregates, source::{ - comment::{Comment, CommentInsertForm, CommentLike, CommentLikeForm}, + comment::{Comment, CommentInsertForm, CommentLike, CommentLikeForm, CommentUpdateForm}, community::{Community, CommunityInsertForm}, instance::Instance, person::{Person, PersonInsertForm}, @@ -138,6 +138,27 @@ mod tests { .unwrap(); assert_eq!(0, after_post_like_remove.post_score); + Comment::update( + pool, + inserted_comment.id, + &CommentUpdateForm::builder().removed(Some(true)).build(), + ) + .await + .unwrap(); + Comment::update( + pool, + inserted_child_comment.id, + &CommentUpdateForm::builder().removed(Some(true)).build(), + ) + .await + .unwrap(); + + let after_parent_comment_removed = PersonAggregates::read(pool, inserted_person.id) + .await + .unwrap(); + assert_eq!(0, after_parent_comment_removed.comment_count); + assert_eq!(0, after_parent_comment_removed.comment_score); + // Remove a parent comment (the scores should also be removed) Comment::delete(pool, inserted_comment.id).await.unwrap(); Comment::delete(pool, inserted_child_comment.id)