mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-21 01:05:31 +00:00
fixup tests
This commit is contained in:
@@ -303,14 +303,11 @@ mod test {
|
||||
);
|
||||
assert_equal!(
|
||||
Command::parse("MAIL From:<>").unwrap(),
|
||||
Command::Mail(EnvelopeAddress::Null)
|
||||
Command::Mail(EnvelopeAddress::null_sender())
|
||||
);
|
||||
assert_equal!(
|
||||
Command::parse("MAIL From:<user@example.com>").unwrap(),
|
||||
Command::Mail(EnvelopeAddress::Mailbox {
|
||||
user: "user".to_string(),
|
||||
domain: "example.com".to_string()
|
||||
})
|
||||
Command::Mail(EnvelopeAddress::parse("user@example.com").unwrap())
|
||||
);
|
||||
assert_equal!(
|
||||
Command::parse("rcpt to:<>").unwrap_err().to_string(),
|
||||
@@ -318,10 +315,7 @@ mod test {
|
||||
);
|
||||
assert_equal!(
|
||||
Command::parse("rcpt TO:<user@example.com>").unwrap(),
|
||||
Command::Rcpt(EnvelopeAddress::Mailbox {
|
||||
user: "user".to_string(),
|
||||
domain: "example.com".to_string()
|
||||
})
|
||||
Command::Rcpt(EnvelopeAddress::parse("user@example.com").unwrap())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ pub struct EnvelopeAddress(String);
|
||||
impl EnvelopeAddress {
|
||||
pub fn parse(text: &str) -> anyhow::Result<Self> {
|
||||
if text.is_empty() {
|
||||
Ok(Self("".to_string()))
|
||||
Ok(Self::null_sender())
|
||||
} else {
|
||||
let fields: Vec<&str> = text.split('@').collect();
|
||||
anyhow::ensure!(fields.len() == 2, "expected user@domain");
|
||||
@@ -30,6 +30,10 @@ impl EnvelopeAddress {
|
||||
None => "",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn null_sender() -> Self {
|
||||
Self("".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl UserData for EnvelopeAddress {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub mod address;
|
||||
pub mod message;
|
||||
|
||||
pub use address::EnvelopeAddress;
|
||||
pub use message::Message;
|
||||
pub use crate::address::EnvelopeAddress;
|
||||
pub use crate::message::Message;
|
||||
|
||||
Reference in New Issue
Block a user