mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 07:16:31 +03:00
add tests for deletion of webxdc status-updates
This commit is contained in:
@@ -837,9 +837,9 @@ mod tests {
|
|||||||
use crate::chatlist::Chatlist;
|
use crate::chatlist::Chatlist;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::contact::Contact;
|
use crate::contact::Contact;
|
||||||
use crate::message;
|
|
||||||
use crate::receive_imf::{receive_imf, receive_imf_inner};
|
use crate::receive_imf::{receive_imf, receive_imf_inner};
|
||||||
use crate::test_utils::TestContext;
|
use crate::test_utils::TestContext;
|
||||||
|
use crate::{message, sql};
|
||||||
|
|
||||||
#[allow(clippy::assertions_on_constants)]
|
#[allow(clippy::assertions_on_constants)]
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
@@ -1216,6 +1216,66 @@ mod tests {
|
|||||||
async fn test_delete_webxdc_instance() -> Result<()> {
|
async fn test_delete_webxdc_instance() -> Result<()> {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "foo").await?;
|
let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "foo").await?;
|
||||||
|
let instance = send_webxdc_instance(&t, chat_id).await?;
|
||||||
|
t.receive_status_update(
|
||||||
|
ContactId::SELF,
|
||||||
|
instance.id,
|
||||||
|
r#"{"updates":[{"payload":1}]}"#,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
assert_eq!(
|
||||||
|
t.sql
|
||||||
|
.count("SELECT COUNT(*) FROM msgs_status_updates;", ())
|
||||||
|
.await?,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
message::delete_msgs(&t, &[instance.id]).await?;
|
||||||
|
sql::housekeeping(&t).await?;
|
||||||
|
assert_eq!(
|
||||||
|
t.sql
|
||||||
|
.count("SELECT COUNT(*) FROM msgs_status_updates;", ())
|
||||||
|
.await?,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_delete_chat_with_webxdc() -> Result<()> {
|
||||||
|
let t = TestContext::new_alice().await;
|
||||||
|
let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "foo").await?;
|
||||||
|
let instance = send_webxdc_instance(&t, chat_id).await?;
|
||||||
|
t.receive_status_update(
|
||||||
|
ContactId::SELF,
|
||||||
|
instance.id,
|
||||||
|
r#"{"updates":[{"payload":1}, {"payload":2}]}"#,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
assert_eq!(
|
||||||
|
t.sql
|
||||||
|
.count("SELECT COUNT(*) FROM msgs_status_updates;", ())
|
||||||
|
.await?,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
chat_id.delete(&t).await?;
|
||||||
|
sql::housekeeping(&t).await?;
|
||||||
|
assert_eq!(
|
||||||
|
t.sql
|
||||||
|
.count("SELECT COUNT(*) FROM msgs_status_updates;", ())
|
||||||
|
.await?,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_delete_webxdc_draft() -> Result<()> {
|
||||||
|
let t = TestContext::new_alice().await;
|
||||||
|
let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "foo").await?;
|
||||||
|
|
||||||
let mut instance = create_webxdc_instance(
|
let mut instance = create_webxdc_instance(
|
||||||
&t,
|
&t,
|
||||||
|
|||||||
Reference in New Issue
Block a user