aerogramme/tests/rfc3691_imapext_unselect.rs

29 lines
1.3 KiB
Rust
Raw Normal View History

2024-01-04 10:23:26 +00:00
use anyhow::Context;
2024-01-03 09:28:10 +00:00
mod common;
2024-01-04 10:23:26 +00:00
use crate::common::fragments::*;
2024-01-03 09:28:10 +00:00
fn main() {
common::aerogramme_provider_daemon_dev(|imap_socket, lmtp_socket| {
2024-01-04 10:23:26 +00:00
connect(imap_socket).context("server says hello")?;
2024-01-03 09:28:10 +00:00
lmtp_handshake(lmtp_socket).context("handshake lmtp done")?;
2024-01-04 10:23:26 +00:00
lmtp_deliver_email(lmtp_socket, Email::Basic).context("mail delivered successfully")?;
2024-01-03 09:28:10 +00:00
2024-01-04 10:23:26 +00:00
capability(imap_socket, Extension::Unselect).context("check server capabilities")?;
login(imap_socket, Account::Alice).context("login test")?;
select(imap_socket, Mailbox::Inbox, None).context("select inbox")?;
2024-01-03 09:28:10 +00:00
noop_exists(imap_socket).context("noop loop must detect a new email")?;
2024-01-04 10:23:26 +00:00
add_flags_email(imap_socket, Selection::FirstId, Flag::Deleted).context("add delete flags to the email")?;
2024-01-03 09:28:10 +00:00
unselect(imap_socket)
.context("unselect inbox while preserving email with the \\Delete flag")?;
2024-01-04 10:23:26 +00:00
select(imap_socket, Mailbox::Inbox, Some(1)).context("select inbox again")?;
fetch_rfc822(imap_socket, Selection::FirstId, Email::Basic).context("message is still present")?;
2024-01-03 09:28:10 +00:00
close(imap_socket).context("close inbox and expunge message")?;
2024-01-04 10:23:26 +00:00
select(imap_socket, Mailbox::Inbox, Some(0)).context("select inbox again and check it's empty")?;
2024-01-03 09:28:10 +00:00
Ok(())
})
.expect("test fully run");
}