aboutsummaryrefslogtreecommitdiff
path: root/src/imap
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-07-05 15:21:14 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-07-05 15:21:14 +0200
commitee9f9e2c4d80ed8263e7a52d48a5df6c4bd8a354 (patch)
tree993094f541309bea1e7d4595b99986925751de56 /src/imap
parentf3f0673c3c6ecd48e7f4bba770cffd70c86cb19c (diff)
downloadaerogramme-ee9f9e2c4d80ed8263e7a52d48a5df6c4bd8a354.tar.gz
aerogramme-ee9f9e2c4d80ed8263e7a52d48a5df6c4bd8a354.zip
First test based on Dovecot results
Diffstat (limited to 'src/imap')
-rw-r--r--src/imap/mailbox_view.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index 9728508..091c8f6 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -646,19 +646,30 @@ fn unchecked_istring(s: &'static str) -> IString {
#[cfg(test)]
mod tests {
use super::*;
+ use imap_codec::codec::Encode;
+ use std::fs;
+ /// Future automated test. We use lossy utf8 conversion + lowercasing everything,
+ /// so this test might allow invalid results. But at least it allows us to quickly test a
+ /// large variety of emails.
+ /// Keep in mind that special cases must still be tested manually!
#[test]
- fn rfc_to_imap() -> Result<()> {
- let txt = br#"From: Garage team <garagehq@deuxfleurs.fr>
-Subject: Welcome to Aerogramme!!
+ fn fetch_body() -> Result<()> {
+ let txt = fs::read("tests/emails/dxflrs/0001_simple.eml")?;
+ let exp = fs::read("tests/emails/dxflrs/0001_simple.body")?;
+ let message = Message::parse(&txt).unwrap();
-This is just a test email, feel free to ignore.
-"#;
- let message = Message::parse(txt).unwrap();
+ let mut resp = Vec::new();
+ MessageAttribute::Body(build_imap_email_struct(&message, &message.structure)?)
+ .encode(&mut resp);
- let bs = build_imap_email_struct(&message, &message.structure)?;
+ let resp_str = String::from_utf8_lossy(&resp).to_lowercase();
- print!("{:?}", bs);
+ let exp_no_parenthesis = &exp[1..exp.len() - 1];
+ let exp_str = String::from_utf8_lossy(exp_no_parenthesis).to_lowercase();
+
+ println!("mine: {}\nexpected: {}", resp_str, exp_str);
+ assert_eq!(resp_str, exp_str);
Ok(())
}