Move the actual logic of email parsing to EmailAddress::new() (#3656)

Very small PR; Motivation: Easier navigation using Go-To-definition.

Because, using go-to-definition of rust-analyzer on parse() doesn't take you to the actual parse() implementation but its trait definiton. On the other hand, it's very easy to find EmailAddress::new().
This commit is contained in:
Hocuri
2022-10-12 20:37:17 +02:00
committed by GitHub
parent 7ed947f598
commit 0e2445c7a0
6 changed files with 28 additions and 29 deletions

View File

@@ -693,6 +693,7 @@ mod tests {
use crate::peerstate::Peerstate;
use crate::receive_imf::receive_imf;
use crate::test_utils::{TestContext, TestContextManager};
use crate::tools::EmailAddress;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_setup_contact() {
@@ -722,7 +723,10 @@ mod tests {
);
let sent = bob.pop_sent_msg().await;
assert_eq!(sent.recipient(), "alice@example.org".parse().unwrap());
assert_eq!(
sent.recipient(),
EmailAddress::new("alice@example.org").unwrap()
);
let msg = alice.parse_msg(&sent).await;
assert!(!msg.was_encrypted());
assert_eq!(msg.get_header(HeaderDef::SecureJoin).unwrap(), "vc-request");
@@ -1087,7 +1091,10 @@ mod tests {
assert_eq!(Chatlist::try_load(&bob, 0, None, None).await?.len(), 1);
let sent = bob.pop_sent_msg().await;
assert_eq!(sent.recipient(), "alice@example.org".parse().unwrap());
assert_eq!(
sent.recipient(),
EmailAddress::new("alice@example.org").unwrap()
);
let msg = alice.parse_msg(&sent).await;
assert!(!msg.was_encrypted());
assert_eq!(msg.get_header(HeaderDef::SecureJoin).unwrap(), "vg-request");