Add missing test cleanup (#4289)

* Add missing test cleanup

* cleanup
This commit is contained in:
Nutomic 2023-12-19 11:26:00 +01:00 committed by GitHub
parent 2899ba0131
commit a507a39336
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View file

@ -210,7 +210,7 @@ mod tests {
.recipient_id(timmy.id) .recipient_id(timmy.id)
.content(message_content.clone()) .content(message_content.clone())
.build(); .build();
let _inserted_sara_timmy_message_form = PrivateMessage::create(pool, &sara_timmy_message_form) PrivateMessage::create(pool, &sara_timmy_message_form)
.await .await
.unwrap(); .unwrap();
@ -219,7 +219,7 @@ mod tests {
.recipient_id(jess.id) .recipient_id(jess.id)
.content(message_content.clone()) .content(message_content.clone())
.build(); .build();
let _inserted_sara_jess_message_form = PrivateMessage::create(pool, &sara_jess_message_form) PrivateMessage::create(pool, &sara_jess_message_form)
.await .await
.unwrap(); .unwrap();
@ -228,7 +228,7 @@ mod tests {
.recipient_id(sara.id) .recipient_id(sara.id)
.content(message_content.clone()) .content(message_content.clone())
.build(); .build();
let _inserted_timmy_sara_message_form = PrivateMessage::create(pool, &timmy_sara_message_form) PrivateMessage::create(pool, &timmy_sara_message_form)
.await .await
.unwrap(); .unwrap();
@ -237,13 +237,13 @@ mod tests {
.recipient_id(timmy.id) .recipient_id(timmy.id)
.content(message_content.clone()) .content(message_content.clone())
.build(); .build();
let _inserted_jess_timmy_message_form = PrivateMessage::create(pool, &jess_timmy_message_form) PrivateMessage::create(pool, &jess_timmy_message_form)
.await .await
.unwrap(); .unwrap();
let timmy_messages = PrivateMessageQuery { let timmy_messages = PrivateMessageQuery {
unread_only: false, unread_only: false,
creator_id: Option::None, creator_id: None,
..Default::default() ..Default::default()
} }
.list(pool, timmy.id) .list(pool, timmy.id)
@ -260,7 +260,7 @@ mod tests {
let timmy_unread_messages = PrivateMessageQuery { let timmy_unread_messages = PrivateMessageQuery {
unread_only: true, unread_only: true,
creator_id: Option::None, creator_id: None,
..Default::default() ..Default::default()
} }
.list(pool, timmy.id) .list(pool, timmy.id)
@ -320,7 +320,7 @@ mod tests {
let timmy_messages = PrivateMessageQuery { let timmy_messages = PrivateMessageQuery {
unread_only: true, unread_only: true,
creator_id: Option::None, creator_id: None,
..Default::default() ..Default::default()
} }
.list(pool, timmy.id) .list(pool, timmy.id)
@ -333,5 +333,8 @@ mod tests {
.await .await
.unwrap(); .unwrap();
assert_eq!(timmy_unread_messages, 1); assert_eq!(timmy_unread_messages, 1);
// This also deletes all persons and private messages thanks to sql `on delete cascade`
Instance::delete(pool, instance.id).await.unwrap();
} }
} }

View file

@ -230,7 +230,6 @@ mod tests {
#[tokio::test] #[tokio::test]
#[serial] #[serial]
#[allow(clippy::dbg_macro)]
async fn exclude_deleted() { async fn exclude_deleted() {
let pool = &build_db_pool_for_tests().await; let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into(); let pool = &mut pool.into();
@ -257,7 +256,6 @@ mod tests {
.list(pool) .list(pool)
.await .await
.unwrap(); .unwrap();
dbg!(&list);
assert_eq!(list.len(), 1); assert_eq!(list.len(), 1);
assert_eq!(list[0].person.id, data.bob.id); assert_eq!(list[0].person.id, data.bob.id);