diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs
index fd503db2e..1a4d16d5b 100644
--- a/src/chat/chat_tests.rs
+++ b/src/chat/chat_tests.rs
@@ -674,8 +674,9 @@ async fn test_modify_chat_lost() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_leave_group() -> Result<()> {
- let alice = TestContext::new_alice().await;
- let bob = TestContext::new_bob().await;
+ let mut tcm = TestContextManager::new();
+ let alice = tcm.alice().await;
+ let bob = tcm.bob().await;
// Create group chat with Bob.
let alice_chat_id = create_group_chat(&alice, ProtectionStatus::Unprotected, "foo").await?;
@@ -2039,8 +2040,9 @@ async fn test_forward_quote() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_forward_group() -> Result<()> {
- let alice = TestContext::new_alice().await;
- let bob = TestContext::new_bob().await;
+ let mut tcm = TestContextManager::new();
+ let alice = tcm.alice().await;
+ let bob = tcm.bob().await;
let alice_chat = alice.create_chat(&bob).await;
let bob_chat = bob.create_chat(&alice).await;
@@ -2903,12 +2905,13 @@ async fn test_sync_blocked() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_sync_accept_before_first_msg() -> Result<()> {
- let alice0 = &TestContext::new_alice().await;
- let alice1 = &TestContext::new_alice().await;
+ let mut tcm = TestContextManager::new();
+ let alice0 = &tcm.alice().await;
+ let alice1 = &tcm.alice().await;
for a in [alice0, alice1] {
a.set_config_bool(Config::SyncMsgs, true).await?;
}
- let bob = TestContext::new_bob().await;
+ let bob = &tcm.bob().await;
let ba_chat = bob.create_chat(alice0).await;
let sent_msg = bob.send_text(ba_chat.id, "hi").await;
@@ -2922,7 +2925,7 @@ async fn test_sync_accept_before_first_msg() -> Result<()> {
a0b_chat_id.accept(alice0).await?;
let a0b_contact = Contact::get_by_id(alice0, a0b_contact_id).await?;
assert_eq!(a0b_contact.origin, Origin::CreateChat);
- assert_eq!(alice0.get_chat(&bob).await.blocked, Blocked::Not);
+ assert_eq!(alice0.get_chat(bob).await.blocked, Blocked::Not);
sync(alice0, alice1).await;
let alice1_contacts = Contact::get_all(alice1, 0, None).await?;
@@ -2931,7 +2934,7 @@ async fn test_sync_accept_before_first_msg() -> Result<()> {
let a1b_contact = Contact::get_by_id(alice1, a1b_contact_id).await?;
assert_eq!(a1b_contact.get_addr(), "bob@example.net");
assert_eq!(a1b_contact.origin, Origin::CreateChat);
- let a1b_chat = alice1.get_chat(&bob).await;
+ let a1b_chat = alice1.get_chat(bob).await;
assert_eq!(a1b_chat.blocked, Blocked::Not);
let chats = Chatlist::try_load(alice1, 0, None, None).await?;
assert_eq!(chats.len(), 1);
@@ -3067,8 +3070,9 @@ async fn test_sync_adhoc_grp() -> Result<()> {
/// - That sync messages don't unarchive the self-chat.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_sync_visibility() -> Result<()> {
- let alice0 = &TestContext::new_alice().await;
- let alice1 = &TestContext::new_alice().await;
+ let mut tcm = TestContextManager::new();
+ let alice0 = &tcm.alice().await;
+ let alice1 = &tcm.alice().await;
for a in [alice0, alice1] {
a.set_config_bool(Config::SyncMsgs, true).await?;
}
@@ -3120,8 +3124,9 @@ async fn test_sync_device_messages_visibility() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_sync_muted() -> Result<()> {
- let alice0 = &TestContext::new_alice().await;
- let alice1 = &TestContext::new_alice().await;
+ let mut tcm = TestContextManager::new();
+ let alice0 = &tcm.alice().await;
+ let alice1 = &tcm.alice().await;
for a in [alice0, alice1] {
a.set_config_bool(Config::SyncMsgs, true).await?;
}
@@ -3155,8 +3160,9 @@ async fn test_sync_muted() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_sync_broadcast() -> Result<()> {
- let alice0 = &TestContext::new_alice().await;
- let alice1 = &TestContext::new_alice().await;
+ let mut tcm = TestContextManager::new();
+ let alice0 = &tcm.alice().await;
+ let alice1 = &tcm.alice().await;
for a in [alice0, alice1] {
a.set_config_bool(Config::SyncMsgs, true).await?;
}
diff --git a/src/contact/contact_tests.rs b/src/contact/contact_tests.rs
index 51534e9f6..c789bdd11 100644
--- a/src/contact/contact_tests.rs
+++ b/src/contact/contact_tests.rs
@@ -1050,8 +1050,9 @@ async fn test_sync_create() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_make_n_import_vcard() -> Result<()> {
- let alice = &TestContext::new_alice().await;
- let bob = &TestContext::new_bob().await;
+ let mut tcm = TestContextManager::new();
+ let alice = &tcm.alice().await;
+ let bob = &tcm.bob().await;
bob.set_config(Config::Displayname, Some("Bob")).await?;
let avatar_path = bob.dir.path().join("avatar.png");
let avatar_bytes = include_bytes!("../../test-data/image/avatar64x64.png");
diff --git a/src/html.rs b/src/html.rs
index ad4538c2b..5ba94ee6c 100644
--- a/src/html.rs
+++ b/src/html.rs
@@ -285,7 +285,7 @@ mod tests {
use crate::contact::ContactId;
use crate::message::{MessengerMessage, Viewtype};
use crate::receive_imf::receive_imf;
- use crate::test_utils::TestContext;
+ use crate::test_utils::{TestContext, TestContextManager};
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_htmlparse_plain_unspecified() {
@@ -442,24 +442,25 @@ test some special html-characters as < > and & but also " and
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_html_forwarding() {
// alice receives a non-delta html-message
- let alice = TestContext::new_alice().await;
+ let mut tcm = TestContextManager::new();
+ let alice = &tcm.alice().await;
let chat = alice
.create_chat_with_contact("", "sender@testrun.org")
.await;
let raw = include_bytes!("../test-data/message/text_alt_plain_html.eml");
- receive_imf(&alice, raw, false).await.unwrap();
+ receive_imf(alice, raw, false).await.unwrap();
let msg = alice.get_last_msg_in(chat.get_id()).await;
assert_ne!(msg.get_from_id(), ContactId::SELF);
assert_eq!(msg.is_dc_message, MessengerMessage::No);
assert!(!msg.is_forwarded());
assert!(msg.get_text().contains("this is plain"));
assert!(msg.has_html());
- let html = msg.get_id().get_html(&alice).await.unwrap().unwrap();
+ let html = msg.get_id().get_html(alice).await.unwrap().unwrap();
assert!(html.contains("this is html"));
// alice: create chat with bob and forward received html-message there
let chat = alice.create_chat_with_contact("", "bob@example.net").await;
- forward_msgs(&alice, &[msg.get_id()], chat.get_id())
+ forward_msgs(alice, &[msg.get_id()], chat.get_id())
.await
.unwrap();
let msg = alice.get_last_msg_in(chat.get_id()).await;
@@ -468,11 +469,11 @@ test some special html-characters as < > and & but also " and
assert!(msg.is_forwarded());
assert!(msg.get_text().contains("this is plain"));
assert!(msg.has_html());
- let html = msg.get_id().get_html(&alice).await.unwrap().unwrap();
+ let html = msg.get_id().get_html(alice).await.unwrap().unwrap();
assert!(html.contains("this is html"));
// bob: check that bob also got the html-part of the forwarded message
- let bob = TestContext::new_bob().await;
+ let bob = &tcm.bob().await;
let chat = bob.create_chat_with_contact("", "alice@example.org").await;
let msg = bob.recv_msg(&alice.pop_sent_msg().await).await;
assert_eq!(chat.id, msg.chat_id);
@@ -481,7 +482,7 @@ test some special html-characters as < > and & but also " and
assert!(msg.is_forwarded());
assert!(msg.get_text().contains("this is plain"));
assert!(msg.has_html());
- let html = msg.get_id().get_html(&bob).await.unwrap().unwrap();
+ let html = msg.get_id().get_html(bob).await.unwrap().unwrap();
assert!(html.contains("this is html"));
}
@@ -519,10 +520,11 @@ test some special html-characters as < > and & but also " and
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_html_forwarding_encrypted() {
+ let mut tcm = TestContextManager::new();
// Alice receives a non-delta html-message
// (`ShowEmails=AcceptedContacts` lets Alice actually receive non-delta messages for known
// contacts, the contact is marked as known by creating a chat using `chat_with_contact()`)
- let alice = TestContext::new_alice().await;
+ let alice = &tcm.alice().await;
alice
.set_config(Config::ShowEmails, Some("1"))
.await
@@ -531,19 +533,19 @@ test some special html-characters as < > and & but also " and
.create_chat_with_contact("", "sender@testrun.org")
.await;
let raw = include_bytes!("../test-data/message/text_alt_plain_html.eml");
- receive_imf(&alice, raw, false).await.unwrap();
+ receive_imf(alice, raw, false).await.unwrap();
let msg = alice.get_last_msg_in(chat.get_id()).await;
// forward the message to saved-messages,
// this will encrypt the message as new_alice() has set up keys
let chat = alice.get_self_chat().await;
- forward_msgs(&alice, &[msg.get_id()], chat.get_id())
+ forward_msgs(alice, &[msg.get_id()], chat.get_id())
.await
.unwrap();
let msg = alice.pop_sent_msg().await;
// receive the message on another device
- let alice = TestContext::new_alice().await;
+ let alice = &tcm.alice().await;
alice
.set_config(Config::ShowEmails, Some("0"))
.await
@@ -556,38 +558,39 @@ test some special html-characters as < > and & but also " and
assert!(msg.is_forwarded());
assert!(msg.get_text().contains("this is plain"));
assert!(msg.has_html());
- let html = msg.get_id().get_html(&alice).await.unwrap().unwrap();
+ let html = msg.get_id().get_html(alice).await.unwrap().unwrap();
assert!(html.contains("this is html"));
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_set_html() {
- let alice = TestContext::new_alice().await;
- let bob = TestContext::new_bob().await;
+ let mut tcm = TestContextManager::new();
+ let alice = &tcm.alice().await;
+ let bob = &tcm.bob().await;
// alice sends a message with html-part to bob
- let chat_id = alice.create_chat(&bob).await.id;
+ let chat_id = alice.create_chat(bob).await.id;
let mut msg = Message::new_text("plain text".to_string());
msg.set_html(Some("html text".to_string()));
assert!(msg.mime_modified);
- chat::send_msg(&alice, chat_id, &mut msg).await.unwrap();
+ chat::send_msg(alice, chat_id, &mut msg).await.unwrap();
// check the message is written correctly to alice's db
let msg = alice.get_last_msg_in(chat_id).await;
assert_eq!(msg.get_text(), "plain text");
assert!(!msg.is_forwarded());
assert!(msg.mime_modified);
- let html = msg.get_id().get_html(&alice).await.unwrap().unwrap();
+ let html = msg.get_id().get_html(alice).await.unwrap().unwrap();
assert!(html.contains("html text"));
// let bob receive the message
- let chat_id = bob.create_chat(&alice).await.id;
+ let chat_id = bob.create_chat(alice).await.id;
let msg = bob.recv_msg(&alice.pop_sent_msg().await).await;
assert_eq!(msg.chat_id, chat_id);
assert_eq!(msg.get_text(), "plain text");
assert!(!msg.is_forwarded());
assert!(msg.mime_modified);
- let html = msg.get_id().get_html(&bob).await.unwrap().unwrap();
+ let html = msg.get_id().get_html(bob).await.unwrap().unwrap();
assert!(html.contains("html text"));
}
diff --git a/src/reaction.rs b/src/reaction.rs
index 4f62bf955..1ade5ad57 100644
--- a/src/reaction.rs
+++ b/src/reaction.rs
@@ -731,8 +731,9 @@ Here's my footer -- bob@example.net"
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_reaction_summary() -> Result<()> {
- let alice = TestContext::new_alice().await;
- let bob = TestContext::new_bob().await;
+ let mut tcm = TestContextManager::new();
+ let alice = tcm.alice().await;
+ let bob = tcm.bob().await;
alice.set_config(Config::Displayname, Some("ALICE")).await?;
bob.set_config(Config::Displayname, Some("BOB")).await?;
let alice_bob_id = alice.add_or_lookup_contact_id(&bob).await;