From 889f4673ad05538d67a3f4e54b73f36785214ec7 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sat, 14 Nov 2020 23:46:30 +0100 Subject: [PATCH] make loading eml reusable --- src/dc_receive_imf.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 9c19fbbf4..c5b7b1b08 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -2718,25 +2718,27 @@ mod tests { assert_eq!(last_msg.from_id, DC_CONTACT_ID_INFO); } - #[async_std::test] - async fn test_html_only_mail() { - let t = TestContext::new_alice().await; - t.ctx + async fn load_imf_email(context: &Context, imf_raw: &[u8]) -> Message { + context .set_config(Config::ShowEmails, Some("2")) .await .unwrap(); - dc_receive_imf( + dc_receive_imf(&context, imf_raw, "INBOX", 0, false) + .await + .unwrap(); + let chats = Chatlist::try_load(&context, 0, None, None).await.unwrap(); + let msg_id = chats.get_msg_id(0).unwrap(); + Message::load_from_db(&context, msg_id).await.unwrap() + } + + #[async_std::test] + async fn test_html_only_mail() { + let t = TestContext::new_alice().await; + let msg = load_imf_email( &t.ctx, include_bytes!("../test-data/message/wrong-html.eml"), - "INBOX", - 0, - false, ) - .await - .unwrap(); - let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap(); - let msg_id = chats.get_msg_id(0).unwrap(); - let msg = Message::load_from_db(&t.ctx, msg_id).await.unwrap(); + .await; assert_eq!(msg.text.unwrap(), " Guten Abend, \n\n Lots of text \n\n text with Umlaut รค... \n\n MfG [...]"); } }