mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 00:06:30 +03:00
rustfmt
This commit is contained in:
24
src/blob.rs
24
src/blob.rs
@@ -536,36 +536,28 @@ mod tests {
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_lowercase_ext() {
|
async fn test_lowercase_ext() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
let blob = BlobObject::create(&t, "foo.TXT", b"hello")
|
let blob = BlobObject::create(&t, "foo.TXT", b"hello").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(blob.as_name(), "$BLOBDIR/foo.txt");
|
assert_eq!(blob.as_name(), "$BLOBDIR/foo.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_as_file_name() {
|
async fn test_as_file_name() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
let blob = BlobObject::create(&t, "foo.txt", b"hello")
|
let blob = BlobObject::create(&t, "foo.txt", b"hello").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(blob.as_file_name(), "foo.txt");
|
assert_eq!(blob.as_file_name(), "foo.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_as_rel_path() {
|
async fn test_as_rel_path() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
let blob = BlobObject::create(&t, "foo.txt", b"hello")
|
let blob = BlobObject::create(&t, "foo.txt", b"hello").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(blob.as_rel_path(), Path::new("foo.txt"));
|
assert_eq!(blob.as_rel_path(), Path::new("foo.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_suffix() {
|
async fn test_suffix() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
let blob = BlobObject::create(&t, "foo.txt", b"hello")
|
let blob = BlobObject::create(&t, "foo.txt", b"hello").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(blob.suffix(), Some("txt"));
|
assert_eq!(blob.suffix(), Some("txt"));
|
||||||
let blob = BlobObject::create(&t, "bar", b"world").await.unwrap();
|
let blob = BlobObject::create(&t, "bar", b"world").await.unwrap();
|
||||||
assert_eq!(blob.suffix(), None);
|
assert_eq!(blob.suffix(), None);
|
||||||
@@ -574,14 +566,10 @@ mod tests {
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_create_dup() {
|
async fn test_create_dup() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
BlobObject::create(&t, "foo.txt", b"hello")
|
BlobObject::create(&t, "foo.txt", b"hello").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let foo_path = t.get_blobdir().join("foo.txt");
|
let foo_path = t.get_blobdir().join("foo.txt");
|
||||||
assert!(foo_path.exists().await);
|
assert!(foo_path.exists().await);
|
||||||
BlobObject::create(&t, "foo.txt", b"world")
|
BlobObject::create(&t, "foo.txt", b"world").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let mut dir = fs::read_dir(t.get_blobdir()).await.unwrap();
|
let mut dir = fs::read_dir(t.get_blobdir()).await.unwrap();
|
||||||
while let Some(dirent) = dir.next().await {
|
while let Some(dirent) = dir.next().await {
|
||||||
let fname = dirent.unwrap().file_name();
|
let fname = dirent.unwrap().file_name();
|
||||||
|
|||||||
@@ -463,9 +463,7 @@ mod tests {
|
|||||||
assert_eq!(chats.get_chat_id(0), chat_id2);
|
assert_eq!(chats.get_chat_id(0), chat_id2);
|
||||||
|
|
||||||
// check chatlist query and archive functionality
|
// check chatlist query and archive functionality
|
||||||
let chats = Chatlist::try_load(&t, 0, Some("b"), None)
|
let chats = Chatlist::try_load(&t, 0, Some("b"), None).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(chats.len(), 1);
|
assert_eq!(chats.len(), 1);
|
||||||
|
|
||||||
let chats = Chatlist::try_load(&t, DC_GCL_ARCHIVED_ONLY, None, None)
|
let chats = Chatlist::try_load(&t, DC_GCL_ARCHIVED_ONLY, None, None)
|
||||||
@@ -522,8 +520,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(chats.len(), 0);
|
assert_eq!(chats.len(), 0);
|
||||||
|
|
||||||
t
|
t.set_stock_translation(StockMessage::SavedMessages, "test-1234-save".to_string())
|
||||||
.set_stock_translation(StockMessage::SavedMessages, "test-1234-save".to_string())
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let chats = Chatlist::try_load(&t, 0, Some("t-1234-s"), None)
|
let chats = Chatlist::try_load(&t, 0, Some("t-1234-s"), None)
|
||||||
@@ -531,8 +528,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(chats.len(), 1);
|
assert_eq!(chats.len(), 1);
|
||||||
|
|
||||||
t
|
t.set_stock_translation(StockMessage::DeviceMessages, "test-5678-babbel".to_string())
|
||||||
.set_stock_translation(StockMessage::DeviceMessages, "test-5678-babbel".to_string())
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let chats = Chatlist::try_load(&t, 0, Some("t-5678-b"), None)
|
let chats = Chatlist::try_load(&t, 0, Some("t-5678-b"), None)
|
||||||
|
|||||||
@@ -321,8 +321,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let avatar_blob = t.get_blobdir().join("avatar.jpg");
|
let avatar_blob = t.get_blobdir().join("avatar.jpg");
|
||||||
assert!(!avatar_blob.exists().await);
|
assert!(!avatar_blob.exists().await);
|
||||||
t
|
t.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
||||||
.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(avatar_blob.exists().await);
|
assert!(avatar_blob.exists().await);
|
||||||
@@ -353,8 +352,7 @@ mod tests {
|
|||||||
assert_eq!(img.width(), 900);
|
assert_eq!(img.width(), 900);
|
||||||
assert_eq!(img.height(), 900);
|
assert_eq!(img.height(), 900);
|
||||||
|
|
||||||
t
|
t.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
||||||
.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let avatar_cfg = t.get_config(Config::Selfavatar).await;
|
let avatar_cfg = t.get_config(Config::Selfavatar).await;
|
||||||
@@ -376,8 +374,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let avatar_blob = t.get_blobdir().join("avatar.png");
|
let avatar_blob = t.get_blobdir().join("avatar.png");
|
||||||
assert!(!avatar_blob.exists().await);
|
assert!(!avatar_blob.exists().await);
|
||||||
t
|
t.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
||||||
.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(avatar_blob.exists().await);
|
assert!(avatar_blob.exists().await);
|
||||||
@@ -397,10 +394,7 @@ mod tests {
|
|||||||
let media_quality = constants::MediaQuality::from_i32(media_quality).unwrap_or_default();
|
let media_quality = constants::MediaQuality::from_i32(media_quality).unwrap_or_default();
|
||||||
assert_eq!(media_quality, constants::MediaQuality::Balanced);
|
assert_eq!(media_quality, constants::MediaQuality::Balanced);
|
||||||
|
|
||||||
t
|
t.set_config(Config::MediaQuality, Some("1")).await.unwrap();
|
||||||
.set_config(Config::MediaQuality, Some("1"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let media_quality = t.get_config_int(Config::MediaQuality).await;
|
let media_quality = t.get_config_int(Config::MediaQuality).await;
|
||||||
assert_eq!(media_quality, 1);
|
assert_eq!(media_quality, 1);
|
||||||
|
|||||||
@@ -616,14 +616,10 @@ mod tests {
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_no_panic_on_bad_credentials() {
|
async fn test_no_panic_on_bad_credentials() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
t
|
t.set_config(Config::Addr, Some("probably@unexistant.addr"))
|
||||||
.set_config(Config::Addr, Some("probably@unexistant.addr"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
t
|
|
||||||
.set_config(Config::MailPw, Some("123456"))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
t.set_config(Config::MailPw, Some("123456")).await.unwrap();
|
||||||
assert!(t.configure().await.is_err());
|
assert!(t.configure().await.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2056,10 +2056,7 @@ mod tests {
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_adhoc_group_show_accepted_contact_unknown() {
|
async fn test_adhoc_group_show_accepted_contact_unknown() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t
|
t.set_config(Config::ShowEmails, Some("1")).await.unwrap();
|
||||||
.set_config(Config::ShowEmails, Some("1"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
dc_receive_imf(&t, GRP_MAIL, "INBOX", 1, false)
|
dc_receive_imf(&t, GRP_MAIL, "INBOX", 1, false)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -2072,13 +2069,8 @@ mod tests {
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_adhoc_group_show_accepted_contact_known() {
|
async fn test_adhoc_group_show_accepted_contact_known() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t
|
t.set_config(Config::ShowEmails, Some("1")).await.unwrap();
|
||||||
.set_config(Config::ShowEmails, Some("1"))
|
Contact::create(&t, "Bob", "bob@example.com").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
Contact::create(&t, "Bob", "bob@example.com")
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
dc_receive_imf(&t, GRP_MAIL, "INBOX", 1, false)
|
dc_receive_imf(&t, GRP_MAIL, "INBOX", 1, false)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -2092,10 +2084,7 @@ mod tests {
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_adhoc_group_show_accepted_contact_accepted() {
|
async fn test_adhoc_group_show_accepted_contact_accepted() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t
|
t.set_config(Config::ShowEmails, Some("1")).await.unwrap();
|
||||||
.set_config(Config::ShowEmails, Some("1"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// accept Bob by accepting a delta-message from Bob
|
// accept Bob by accepting a delta-message from Bob
|
||||||
dc_receive_imf(&t, MSGRMSG, "INBOX", 1, false)
|
dc_receive_imf(&t, MSGRMSG, "INBOX", 1, false)
|
||||||
@@ -2138,10 +2127,7 @@ mod tests {
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_adhoc_group_show_all() {
|
async fn test_adhoc_group_show_all() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t
|
t.set_config(Config::ShowEmails, Some("2")).await.unwrap();
|
||||||
.set_config(Config::ShowEmails, Some("2"))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
dc_receive_imf(&t, GRP_MAIL, "INBOX", 1, false)
|
dc_receive_imf(&t, GRP_MAIL, "INBOX", 1, false)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -2164,9 +2150,7 @@ mod tests {
|
|||||||
// create alice's account
|
// create alice's account
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
|
|
||||||
let bob_id = Contact::create(&t, "bob", "bob@example.com")
|
let bob_id = Contact::create(&t, "bob", "bob@example.com").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let one2one_id = chat::create_by_contact_id(&t, bob_id).await.unwrap();
|
let one2one_id = chat::create_by_contact_id(&t, bob_id).await.unwrap();
|
||||||
one2one_id
|
one2one_id
|
||||||
.set_visibility(&t, ChatVisibility::Archived)
|
.set_visibility(&t, ChatVisibility::Archived)
|
||||||
@@ -2180,10 +2164,7 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
chat::add_contact_to_chat(&t, group_id, bob_id).await;
|
chat::add_contact_to_chat(&t, group_id, bob_id).await;
|
||||||
assert_eq!(
|
assert_eq!(chat::get_chat_msgs(&t, group_id, 0, None).await.len(), 0);
|
||||||
chat::get_chat_msgs(&t, group_id, 0, None).await.len(),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
group_id
|
group_id
|
||||||
.set_visibility(&t, ChatVisibility::Archived)
|
.set_visibility(&t, ChatVisibility::Archived)
|
||||||
.await
|
.await
|
||||||
@@ -2231,9 +2212,7 @@ mod tests {
|
|||||||
} else {
|
} else {
|
||||||
panic!("Wrong item type");
|
panic!("Wrong item type");
|
||||||
};
|
};
|
||||||
let msg = message::Message::load_from_db(&t, *msg_id)
|
let msg = message::Message::load_from_db(&t, *msg_id).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(msg.is_dc_message, MessengerMessage::Yes);
|
assert_eq!(msg.is_dc_message, MessengerMessage::Yes);
|
||||||
assert_eq!(msg.text.unwrap(), "hello");
|
assert_eq!(msg.text.unwrap(), "hello");
|
||||||
assert_eq!(msg.state, MessageState::OutDelivered);
|
assert_eq!(msg.state, MessageState::OutDelivered);
|
||||||
@@ -2278,13 +2257,8 @@ mod tests {
|
|||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.await.unwrap();
|
.await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(chat::get_chat_msgs(&t, group_id, 0, None).await.len(), 1);
|
||||||
chat::get_chat_msgs(&t, group_id, 0, None).await.len(),
|
let msg = message::Message::load_from_db(&t, *msg_id).await.unwrap();
|
||||||
1
|
|
||||||
);
|
|
||||||
let msg = message::Message::load_from_db(&t, *msg_id)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(msg.state, MessageState::OutMdnRcvd);
|
assert_eq!(msg.state, MessageState::OutMdnRcvd);
|
||||||
|
|
||||||
// check, the read-receipt has not unarchived the one2one
|
// check, the read-receipt has not unarchived the one2one
|
||||||
@@ -2338,9 +2312,7 @@ mod tests {
|
|||||||
let contact_id = Contact::create(&t, "foobar", "foobar@example.com")
|
let contact_id = Contact::create(&t, "foobar", "foobar@example.com")
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let chat_id = chat::create_by_contact_id(&t, contact_id)
|
let chat_id = chat::create_by_contact_id(&t, contact_id).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
dc_receive_imf(
|
dc_receive_imf(
|
||||||
&t,
|
&t,
|
||||||
b"From: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= <foobar@example.com>\n\
|
b"From: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= <foobar@example.com>\n\
|
||||||
@@ -2370,9 +2342,7 @@ mod tests {
|
|||||||
} else {
|
} else {
|
||||||
panic!("Wrong item type");
|
panic!("Wrong item type");
|
||||||
};
|
};
|
||||||
let msg = message::Message::load_from_db(&t, *msg_id)
|
let msg = message::Message::load_from_db(&t, *msg_id).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(msg.is_dc_message, MessengerMessage::Yes);
|
assert_eq!(msg.is_dc_message, MessengerMessage::Yes);
|
||||||
assert_eq!(msg.text.unwrap(), "hello");
|
assert_eq!(msg.text.unwrap(), "hello");
|
||||||
assert_eq!(msg.param.get_int(Param::WantsMdn).unwrap(), 1);
|
assert_eq!(msg.param.get_int(Param::WantsMdn).unwrap(), 1);
|
||||||
@@ -2433,12 +2403,8 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let carl_contact_id = Contact::add_or_lookup(
|
let carl_contact_id =
|
||||||
&t,
|
Contact::add_or_lookup(&t, "garabage", "carl@host.tld", Origin::IncomingUnknownFrom)
|
||||||
"garabage",
|
|
||||||
"carl@host.tld",
|
|
||||||
Origin::IncomingUnknownFrom,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.0;
|
.0;
|
||||||
@@ -2624,9 +2590,7 @@ mod tests {
|
|||||||
let msg_id = chats.get_msg_id(0).unwrap();
|
let msg_id = chats.get_msg_id(0).unwrap();
|
||||||
|
|
||||||
let raw = include_bytes!("../test-data/message/gmail_ndn_group.eml");
|
let raw = include_bytes!("../test-data/message/gmail_ndn_group.eml");
|
||||||
dc_receive_imf(&t, raw, "INBOX", 1, false)
|
dc_receive_imf(&t, raw, "INBOX", 1, false).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let msg = Message::load_from_db(&t, msg_id).await.unwrap();
|
let msg = Message::load_from_db(&t, msg_id).await.unwrap();
|
||||||
|
|
||||||
@@ -2643,8 +2607,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
last_msg.text,
|
last_msg.text,
|
||||||
Some(
|
Some(
|
||||||
t
|
t.stock_string_repl_str(
|
||||||
.stock_string_repl_str(
|
|
||||||
StockMessage::FailedSendingTo,
|
StockMessage::FailedSendingTo,
|
||||||
"assidhfaaspocwaeofi@gmail.com",
|
"assidhfaaspocwaeofi@gmail.com",
|
||||||
)
|
)
|
||||||
@@ -2670,11 +2633,7 @@ mod tests {
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_html_only_mail() {
|
async fn test_html_only_mail() {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
let msg = load_imf_email(
|
let msg = load_imf_email(&t, include_bytes!("../test-data/message/wrong-html.eml")).await;
|
||||||
&t,
|
|
||||||
include_bytes!("../test-data/message/wrong-html.eml"),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
assert_eq!(msg.text.unwrap(), " Guten Abend, \n\n Lots of text \n\n text with Umlaut ä... \n\n MfG [...]");
|
assert_eq!(msg.text.unwrap(), " Guten Abend, \n\n Lots of text \n\n text with Umlaut ä... \n\n MfG [...]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -567,8 +567,7 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_load_self_generate_public() {
|
async fn test_load_self_generate_public() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
t
|
t.set_config(Config::ConfiguredAddr, Some("alice@example.com"))
|
||||||
.set_config(Config::ConfiguredAddr, Some("alice@example.com"))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let key = SignedPublicKey::load_self(&t).await;
|
let key = SignedPublicKey::load_self(&t).await;
|
||||||
@@ -578,8 +577,7 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD
|
|||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_load_self_generate_secret() {
|
async fn test_load_self_generate_secret() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
t
|
t.set_config(Config::ConfiguredAddr, Some("alice@example.com"))
|
||||||
.set_config(Config::ConfiguredAddr, Some("alice@example.com"))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let key = SignedSecretKey::load_self(&t).await;
|
let key = SignedSecretKey::load_self(&t).await;
|
||||||
@@ -591,8 +589,7 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
t
|
t.set_config(Config::ConfiguredAddr, Some("alice@example.com"))
|
||||||
.set_config(Config::ConfiguredAddr, Some("alice@example.com"))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let ctx = t.clone();
|
let ctx = t.clone();
|
||||||
|
|||||||
@@ -1417,8 +1417,7 @@ mod tests {
|
|||||||
assert_eq!(first_subject_str(t).await, "Message from alice@example.com");
|
assert_eq!(first_subject_str(t).await, "Message from alice@example.com");
|
||||||
|
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
t
|
t.set_config(Config::Displayname, Some("Alice"))
|
||||||
.set_config(Config::Displayname, Some("Alice"))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(first_subject_str(t).await, "Message from Alice");
|
assert_eq!(first_subject_str(t).await, "Message from Alice");
|
||||||
@@ -1492,9 +1491,7 @@ mod tests {
|
|||||||
Original-Message-ID: <2893@example.com>\n\
|
Original-Message-ID: <2893@example.com>\n\
|
||||||
Disposition: manual-action/MDN-sent-automatically; displayed\n\
|
Disposition: manual-action/MDN-sent-automatically; displayed\n\
|
||||||
\n", &t).await;
|
\n", &t).await;
|
||||||
let mf = MimeFactory::from_msg(&t, &new_msg, false)
|
let mf = MimeFactory::from_msg(&t, &new_msg, false).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
// The subject string should not be "Re: message opened"
|
// The subject string should not be "Re: message opened"
|
||||||
assert_eq!("Re: Hello, Charlie", mf.subject_str().await);
|
assert_eq!("Re: Hello, Charlie", mf.subject_str().await);
|
||||||
}
|
}
|
||||||
@@ -1506,20 +1503,14 @@ mod tests {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.0;
|
.0;
|
||||||
|
|
||||||
let chat_id = chat::create_by_contact_id(&t, contact_id)
|
let chat_id = chat::create_by_contact_id(&t, contact_id).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut new_msg = Message::new(Viewtype::Text);
|
let mut new_msg = Message::new(Viewtype::Text);
|
||||||
new_msg.set_text(Some("Hi".to_string()));
|
new_msg.set_text(Some("Hi".to_string()));
|
||||||
new_msg.chat_id = chat_id;
|
new_msg.chat_id = chat_id;
|
||||||
chat::prepare_msg(&t, chat_id, &mut new_msg)
|
chat::prepare_msg(&t, chat_id, &mut new_msg).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mf = MimeFactory::from_msg(&t, &new_msg, false)
|
let mf = MimeFactory::from_msg(&t, &new_msg, false).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
mf.subject_str().await
|
mf.subject_str().await
|
||||||
}
|
}
|
||||||
@@ -1527,9 +1518,7 @@ mod tests {
|
|||||||
async fn msg_to_subject_str(imf_raw: &[u8]) -> String {
|
async fn msg_to_subject_str(imf_raw: &[u8]) -> String {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
let new_msg = incoming_msg_to_reply_msg(imf_raw, &t).await;
|
let new_msg = incoming_msg_to_reply_msg(imf_raw, &t).await;
|
||||||
let mf = MimeFactory::from_msg(&t, &new_msg, false)
|
let mf = MimeFactory::from_msg(&t, &new_msg, false).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
mf.subject_str().await
|
mf.subject_str().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1793,9 +1793,7 @@ mod tests {
|
|||||||
let raw = include_bytes!("../test-data/message/mail_with_user_and_group_avatars.eml");
|
let raw = include_bytes!("../test-data/message/mail_with_user_and_group_avatars.eml");
|
||||||
let raw = String::from_utf8_lossy(raw).to_string();
|
let raw = String::from_utf8_lossy(raw).to_string();
|
||||||
let raw = raw.replace("Chat-User-Avatar:", "Xhat-Xser-Xvatar:");
|
let raw = raw.replace("Chat-User-Avatar:", "Xhat-Xser-Xvatar:");
|
||||||
let mimeparser = MimeMessage::from_bytes(&t, raw.as_bytes())
|
let mimeparser = MimeMessage::from_bytes(&t, raw.as_bytes()).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(mimeparser.parts.len(), 1);
|
assert_eq!(mimeparser.parts.len(), 1);
|
||||||
assert_eq!(mimeparser.parts[0].typ, Viewtype::Image);
|
assert_eq!(mimeparser.parts[0].typ, Viewtype::Image);
|
||||||
assert_eq!(mimeparser.user_avatar, None);
|
assert_eq!(mimeparser.user_avatar, None);
|
||||||
|
|||||||
28
src/param.rs
28
src/param.rs
@@ -476,36 +476,18 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs::write(fname, b"boo").await.unwrap();
|
fs::write(fname, b"boo").await.unwrap();
|
||||||
let blob = p
|
let blob = p.get_blob(Param::File, &t, true).await.unwrap().unwrap();
|
||||||
.get_blob(Param::File, &t, true)
|
assert_eq!(blob, BlobObject::from_name(&t, "foo".to_string()).unwrap());
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
blob,
|
|
||||||
BlobObject::from_name(&t, "foo".to_string()).unwrap()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Blob in blobdir, expect blob.
|
// Blob in blobdir, expect blob.
|
||||||
let bar_path = t.get_blobdir().join("bar");
|
let bar_path = t.get_blobdir().join("bar");
|
||||||
p.set(Param::File, bar_path.to_str().unwrap());
|
p.set(Param::File, bar_path.to_str().unwrap());
|
||||||
let blob = p
|
let blob = p.get_blob(Param::File, &t, false).await.unwrap().unwrap();
|
||||||
.get_blob(Param::File, &t, false)
|
assert_eq!(blob, BlobObject::from_name(&t, "bar".to_string()).unwrap());
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
blob,
|
|
||||||
BlobObject::from_name(&t, "bar".to_string()).unwrap()
|
|
||||||
);
|
|
||||||
|
|
||||||
p.remove(Param::File);
|
p.remove(Param::File);
|
||||||
assert!(p.get_file(Param::File, &t).unwrap().is_none());
|
assert!(p.get_file(Param::File, &t).unwrap().is_none());
|
||||||
assert!(p.get_path(Param::File, &t).unwrap().is_none());
|
assert!(p.get_path(Param::File, &t).unwrap().is_none());
|
||||||
assert!(p
|
assert!(p.get_blob(Param::File, &t, false).await.unwrap().is_none());
|
||||||
.get_blob(Param::File, &t, false)
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.is_none());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user