Fixing unit tests.

This commit is contained in:
Dessalines 2021-04-07 15:22:34 -04:00
parent b108938274
commit d60a58bd6e
9 changed files with 30 additions and 4 deletions

View file

@ -141,5 +141,9 @@ mod tests {
Person::delete(&conn, another_inserted_person.id).unwrap();
let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap();
assert_eq!(1, person_num_deleted);
// Delete the community
let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap();
assert_eq!(1, community_num_deleted);
}
}

View file

@ -167,6 +167,14 @@ mod tests {
let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap();
assert_eq!(1, person_num_deleted);
// Delete the community
let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap();
assert_eq!(1, community_num_deleted);
let another_community_num_deleted =
Community::delete(&conn, another_inserted_community.id).unwrap();
assert_eq!(1, another_community_num_deleted);
// Should be none found, since the creator was deleted
let after_delete = CommunityAggregates::read(&conn, inserted_community.id);
assert!(after_delete.is_err());

View file

@ -159,6 +159,10 @@ mod tests {
assert_eq!(1, person_num_deleted);
Person::delete(&conn, another_inserted_person.id).unwrap();
// Delete the community
let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap();
assert_eq!(1, community_num_deleted);
// Should be none found
let after_delete = PersonAggregates::read(&conn, inserted_person.id);
assert!(after_delete.is_err());

View file

@ -148,6 +148,10 @@ mod tests {
let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap();
assert_eq!(1, person_num_deleted);
// Delete the community
let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap();
assert_eq!(1, community_num_deleted);
// Should be none found, since the creator was deleted
let after_delete = PostAggregates::read(&conn, inserted_post.id);
assert!(after_delete.is_err());

View file

@ -118,6 +118,10 @@ mod tests {
let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap();
assert_eq!(1, person_num_deleted);
// Delete the community
let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap();
assert_eq!(1, community_num_deleted);
let after_delete = SiteAggregates::read(&conn);
assert!(after_delete.is_err());
}

View file

@ -231,6 +231,7 @@ mod tests {
let new_post = PostForm {
name: "A test post thweep".into(),
creator_id: inserted_person.id,
community_id: inserted_community.id,
..PostForm::default()
};

View file

@ -112,6 +112,7 @@ mod tests {
let new_post = PostForm {
name: "A test post".into(),
creator_id: inserted_person.id,
community_id: inserted_community.id,
..PostForm::default()
};

View file

@ -56,8 +56,8 @@ pub struct CommentAlias1 {
pub struct CommentForm {
pub creator_id: PersonId,
pub post_id: PostId,
pub parent_id: Option<CommentId>,
pub content: String,
pub parent_id: Option<CommentId>,
pub removed: Option<bool>,
pub read: Option<bool>,
pub published: Option<chrono::NaiveDateTime>,

View file

@ -35,16 +35,16 @@ pub struct Post {
#[table_name = "post"]
pub struct PostForm {
pub name: String,
pub url: Option<DbUrl>,
pub body: Option<String>,
pub creator_id: PersonId,
pub community_id: CommunityId,
pub nsfw: bool,
pub url: Option<DbUrl>,
pub body: Option<String>,
pub removed: Option<bool>,
pub locked: Option<bool>,
pub published: Option<chrono::NaiveDateTime>,
pub updated: Option<chrono::NaiveDateTime>,
pub deleted: Option<bool>,
pub nsfw: bool,
pub stickied: Option<bool>,
pub embed_title: Option<String>,
pub embed_description: Option<String>,