X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_schema%2Fsrc%2Faggregates%2Fcommunity_aggregates.rs;h=1a2c4d2477f9ab75f4b960e665e4baeb16c4112b;hb=235cc8b22897bfb3e71ba3dbd725d36863fea8ba;hp=9dfa710fbea0531bf2da8999d27896dbbb830374;hpb=276a8c2bd3e4fd1323e66b808675cf14cf6f75c5;p=lemmy.git diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index 9dfa710f..1a2c4d24 100644 --- a/crates/db_schema/src/aggregates/community_aggregates.rs +++ b/crates/db_schema/src/aggregates/community_aggregates.rs @@ -18,10 +18,11 @@ mod tests { use crate::{ aggregates::community_aggregates::CommunityAggregates, source::{ - comment::{Comment, CommentForm}, - community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm}, - person::{Person, PersonForm}, - post::{Post, PostForm}, + comment::{Comment, CommentInsertForm}, + community::{Community, CommunityFollower, CommunityFollowerForm, CommunityInsertForm}, + instance::Instance, + person::{Person, PersonInsertForm}, + post::{Post, PostInsertForm}, }, traits::{Crud, Followable}, utils::establish_unpooled_connection, @@ -33,37 +34,39 @@ mod tests { fn test_crud() { let conn = &mut establish_unpooled_connection(); - let new_person = PersonForm { - name: "thommy_community_agg".into(), - public_key: Some("pubkey".to_string()), - ..PersonForm::default() - }; + let inserted_instance = Instance::create(conn, "my_domain.tld").unwrap(); + + let new_person = PersonInsertForm::builder() + .name("thommy_community_agg".into()) + .public_key("pubkey".to_string()) + .instance_id(inserted_instance.id) + .build(); let inserted_person = Person::create(conn, &new_person).unwrap(); - let another_person = PersonForm { - name: "jerry_community_agg".into(), - public_key: Some("pubkey".to_string()), - ..PersonForm::default() - }; + let another_person = PersonInsertForm::builder() + .name("jerry_community_agg".into()) + .public_key("pubkey".to_string()) + .instance_id(inserted_instance.id) + .build(); let another_inserted_person = Person::create(conn, &another_person).unwrap(); - let new_community = CommunityForm { - name: "TIL_community_agg".into(), - title: "nada".to_owned(), - public_key: Some("pubkey".to_string()), - ..CommunityForm::default() - }; + let new_community = CommunityInsertForm::builder() + .name("TIL_community_agg".into()) + .title("nada".to_owned()) + .public_key("pubkey".to_string()) + .instance_id(inserted_instance.id) + .build(); let inserted_community = Community::create(conn, &new_community).unwrap(); - let another_community = CommunityForm { - name: "TIL_community_agg_2".into(), - title: "nada".to_owned(), - public_key: Some("pubkey".to_string()), - ..CommunityForm::default() - }; + let another_community = CommunityInsertForm::builder() + .name("TIL_community_agg_2".into()) + .title("nada".to_owned()) + .public_key("pubkey".to_string()) + .instance_id(inserted_instance.id) + .build(); let another_inserted_community = Community::create(conn, &another_community).unwrap(); @@ -91,30 +94,27 @@ mod tests { CommunityFollower::follow(conn, &another_community_follow).unwrap(); - let new_post = PostForm { - name: "A test post".into(), - creator_id: inserted_person.id, - community_id: inserted_community.id, - ..PostForm::default() - }; + let new_post = PostInsertForm::builder() + .name("A test post".into()) + .creator_id(inserted_person.id) + .community_id(inserted_community.id) + .build(); let inserted_post = Post::create(conn, &new_post).unwrap(); - let comment_form = CommentForm { - content: "A test comment".into(), - creator_id: inserted_person.id, - post_id: inserted_post.id, - ..CommentForm::default() - }; + let comment_form = CommentInsertForm::builder() + .content("A test comment".into()) + .creator_id(inserted_person.id) + .post_id(inserted_post.id) + .build(); let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); - let child_comment_form = CommentForm { - content: "A test comment".into(), - creator_id: inserted_person.id, - post_id: inserted_post.id, - ..CommentForm::default() - }; + let child_comment_form = CommentInsertForm::builder() + .content("A test comment".into()) + .creator_id(inserted_person.id) + .post_id(inserted_post.id) + .build(); let _inserted_child_comment = Comment::create(conn, &child_comment_form, Some(&inserted_comment.path)).unwrap();