aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2024-01-06 10:38:37 +0000
committerQuentin <quentin@dufour.io>2024-01-06 10:38:37 +0000
commit44ca458c5cf666246e472dea9be70b745a130e8c (patch)
treeb78cca747e5c2bc004cb93b93536623f7abb6ef5 /tests
parentbcf6de83419b405fea95b740869f98d43586ea7c (diff)
parent53dbf82cbce3cb17cbcffd09558677faf8702f54 (diff)
downloadaerogramme-44ca458c5cf666246e472dea9be70b745a130e8c.tar.gz
aerogramme-44ca458c5cf666246e472dea9be70b745a130e8c.zip
Merge pull request 'Aerogramme refactoring' (#57) from feat/more-imap-qol into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/aerogramme/pulls/57
Diffstat (limited to 'tests')
-rw-r--r--tests/behavior.rs24
-rw-r--r--tests/common/fragments.rs6
2 files changed, 18 insertions, 12 deletions
diff --git a/tests/behavior.rs b/tests/behavior.rs
index 82fdc53..17f3a72 100644
--- a/tests/behavior.rs
+++ b/tests/behavior.rs
@@ -26,15 +26,18 @@ fn rfc3501_imap4rev1_base() {
lmtp_handshake(lmtp_socket).context("handshake lmtp done")?;
lmtp_deliver_email(lmtp_socket, Email::Multipart).context("mail delivered successfully")?;
noop_exists(imap_socket).context("noop loop must detect a new email")?;
- fetch_rfc822(imap_socket, Selection::FirstId, Email::Multipart).context("fetch rfc822 message, should be our first message")?;
- copy(imap_socket, Selection::FirstId, Mailbox::Archive).context("copy message to the archive mailbox")?;
+ fetch_rfc822(imap_socket, Selection::FirstId, Email::Multipart)
+ .context("fetch rfc822 message, should be our first message")?;
+ copy(imap_socket, Selection::FirstId, Mailbox::Archive)
+ .context("copy message to the archive mailbox")?;
append_email(imap_socket, Email::Basic).context("insert email in INBOX")?;
// SEARCH IS NOT IMPLEMENTED YET
//search(imap_socket).expect("search should return something");
add_flags_email(imap_socket, Selection::FirstId, Flag::Deleted)
.context("should add delete flag to the email")?;
expunge(imap_socket).context("expunge emails")?;
- rename_mailbox(imap_socket, Mailbox::Archive, Mailbox::Drafts).context("Archive mailbox is renamed Drafts")?;
+ rename_mailbox(imap_socket, Mailbox::Archive, Mailbox::Drafts)
+ .context("Archive mailbox is renamed Drafts")?;
delete_mailbox(imap_socket, Mailbox::Drafts).context("Drafts mailbox is deleted")?;
Ok(())
})
@@ -53,13 +56,16 @@ fn rfc3691_imapext_unselect() {
login(imap_socket, Account::Alice).context("login test")?;
select(imap_socket, Mailbox::Inbox, None).context("select inbox")?;
noop_exists(imap_socket).context("noop loop must detect a new email")?;
- add_flags_email(imap_socket, Selection::FirstId, Flag::Deleted).context("add delete flags to the email")?;
+ add_flags_email(imap_socket, Selection::FirstId, Flag::Deleted)
+ .context("add delete flags to the email")?;
unselect(imap_socket)
.context("unselect inbox while preserving email with the \\Delete flag")?;
select(imap_socket, Mailbox::Inbox, Some(1)).context("select inbox again")?;
- fetch_rfc822(imap_socket, Selection::FirstId, Email::Basic).context("message is still present")?;
+ fetch_rfc822(imap_socket, Selection::FirstId, Email::Basic)
+ .context("message is still present")?;
close(imap_socket).context("close inbox and expunge message")?;
- select(imap_socket, Mailbox::Inbox, Some(0)).context("select inbox again and check it's empty")?;
+ select(imap_socket, Mailbox::Inbox, Some(0))
+ .context("select inbox again and check it's empty")?;
Ok(())
})
@@ -94,7 +100,8 @@ fn rfc6851_imapext_move() {
lmtp_deliver_email(lmtp_socket, Email::Basic).context("mail delivered successfully")?;
noop_exists(imap_socket).context("noop loop must detect a new email")?;
- r#move(imap_socket, Selection::FirstId, Mailbox::Archive).context("message from inbox moved to archive")?;
+ r#move(imap_socket, Selection::FirstId, Mailbox::Archive)
+ .context("message from inbox moved to archive")?;
unselect(imap_socket)
.context("unselect inbox while preserving email with the \\Delete flag")?;
@@ -116,5 +123,6 @@ fn rfc7888_imapext_literal() {
login_with_literal(imap_socket, Account::Alice).context("use literal to connect Alice")?;
Ok(())
- }).expect("test fully run");
+ })
+ .expect("test fully run");
}
diff --git a/tests/common/fragments.rs b/tests/common/fragments.rs
index 3ed14cc..2e2fbd4 100644
--- a/tests/common/fragments.rs
+++ b/tests/common/fragments.rs
@@ -52,7 +52,7 @@ pub enum Mailbox {
pub enum Flag {
Deleted,
- Important
+ Important,
}
pub enum Email {
@@ -287,8 +287,6 @@ pub fn append_email(imap: &mut TcpStream, content: Email) -> Result<()> {
Ok(())
}
-
-
pub fn add_flags_email(imap: &mut TcpStream, selection: Selection, flag: Flag) -> Result<()> {
let mut buffer: [u8; 1500] = [0; 1500];
assert!(matches!(selection, Selection::FirstId));
@@ -390,7 +388,7 @@ pub fn enable(imap: &mut TcpStream, ask: Enable, done: Option<Enable>) -> Result
Some(Enable::Utf8Accept) => {
assert_eq!(srv_msg.lines().count(), 2);
assert!(srv_msg.contains("* ENABLED UTF8=ACCEPT"));
- },
+ }
_ => unimplemented!(),
}