- // Delete everything
- let like_removed =
- CommentLike::remove(&conn, inserted_person.id, inserted_comment_0.id).unwrap();
- let num_deleted = Comment::delete(&conn, inserted_comment_0.id).unwrap();
- Comment::delete(&conn, inserted_comment_1.id).unwrap();
- Post::delete(&conn, inserted_post.id).unwrap();
- Community::delete(&conn, inserted_community.id).unwrap();
- Person::delete(&conn, inserted_person.id).unwrap();
- Person::delete(&conn, inserted_person_2.id).unwrap();
-
- assert_eq!(1, num_deleted);
- assert_eq!(1, like_removed);
+ cleanup(data, &conn);
+ }
+
+ fn cleanup(data: Data, conn: &PgConnection) {
+ CommentLike::remove(&conn, data.inserted_person.id, data.inserted_comment_0.id).unwrap();
+ Comment::delete(&conn, data.inserted_comment_0.id).unwrap();
+ Comment::delete(&conn, data.inserted_comment_1.id).unwrap();
+ Post::delete(&conn, data.inserted_post.id).unwrap();
+ Community::delete(&conn, data.inserted_community.id).unwrap();
+ Person::delete(&conn, data.inserted_person.id).unwrap();
+ Person::delete(&conn, data.inserted_person_2.id).unwrap();
+ }
+
+ fn expected_comment_view(data: &Data, conn: &PgConnection) -> CommentView {
+ let agg = CommentAggregates::read(&conn, data.inserted_comment_0.id).unwrap();
+ CommentView {
+ creator_banned_from_community: false,
+ my_vote: None,
+ subscribed: SubscribedType::NotSubscribed,
+ saved: false,
+ creator_blocked: false,
+ comment: Comment {
+ id: data.inserted_comment_0.id,
+ content: "Comment 0".into(),
+ creator_id: data.inserted_person.id,
+ post_id: data.inserted_post.id,
+ removed: false,
+ deleted: false,
+ published: data.inserted_comment_0.published,
+ ap_id: data.inserted_comment_0.ap_id.clone(),
+ updated: None,
+ local: true,
+ distinguished: false,
+ path: data.inserted_comment_0.to_owned().path,
+ language_id: LanguageId(0),
+ },
+ creator: PersonSafe {
+ id: data.inserted_person.id,
+ name: "timmy".into(),
+ display_name: None,
+ published: data.inserted_person.published,
+ avatar: None,
+ actor_id: data.inserted_person.actor_id.to_owned(),
+ local: true,
+ banned: false,
+ deleted: false,
+ admin: false,
+ bot_account: false,
+ bio: None,
+ banner: None,
+ updated: None,
+ inbox_url: data.inserted_person.inbox_url.to_owned(),
+ shared_inbox_url: None,
+ matrix_user_id: None,
+ ban_expires: None,
+ },
+ post: Post {
+ id: data.inserted_post.id,
+ name: data.inserted_post.name.to_owned(),
+ creator_id: data.inserted_person.id,
+ url: None,
+ body: None,
+ published: data.inserted_post.published,
+ updated: None,
+ community_id: data.inserted_community.id,
+ removed: false,
+ deleted: false,
+ locked: false,
+ stickied: false,
+ nsfw: false,
+ embed_title: None,
+ embed_description: None,
+ embed_video_url: None,
+ thumbnail_url: None,
+ ap_id: data.inserted_post.ap_id.to_owned(),
+ local: true,
+ language_id: Default::default(),
+ },
+ community: CommunitySafe {
+ id: data.inserted_community.id,
+ name: "test community 5".to_string(),
+ icon: None,
+ removed: false,
+ deleted: false,
+ nsfw: false,
+ actor_id: data.inserted_community.actor_id.to_owned(),
+ local: true,
+ title: "nada".to_owned(),
+ description: None,
+ updated: None,
+ banner: None,
+ hidden: false,
+ posting_restricted_to_mods: false,
+ published: data.inserted_community.published,
+ },
+ counts: CommentAggregates {
+ id: agg.id,
+ comment_id: data.inserted_comment_0.id,
+ score: 1,
+ upvotes: 1,
+ downvotes: 0,
+ published: agg.published,
+ child_count: 5,
+ },
+ }