client: Add UID EXPUNGE support

This commit is contained in:
Massimiliano Torromeo 2018-10-04 11:57:45 +02:00
parent 1a62f1b24b
commit c9b720155f
No known key found for this signature in database
GPG key ID: 11675C743429DDEF

View file

@ -532,6 +532,12 @@ impl <T: Read + Write> Session<T> {
self.run_command_and_check_ok("EXPUNGE")
}
/// Permanently removes all messages that have both the \Deleted flag set and have a UID that is
/// included in the specified message set.
pub fn uid_expunge(&mut self, uid_set: &str) -> Result<()> {
self.run_command_and_check_ok(&format!("UID EXPUNGE {}", uid_set))
}
/// Check requests a checkpoint of the currently selected mailbox.
pub fn check(&mut self) -> Result<()> {
self.run_command_and_check_ok("CHECK")
@ -960,6 +966,21 @@ mod tests {
);
}
#[test]
fn uid_expunge() {
let response = b"* 2 EXPUNGE\r\n\
* 3 EXPUNGE\r\n\
* 4 EXPUNGE\r\n\
a1 OK UID EXPUNGE completed\r\n".to_vec();
let mock_stream = MockStream::new(response);
let mut session = mock_session!(mock_stream);
session.uid_expunge("2:4").unwrap();
assert!(
session.stream.get_ref().written_buf == b"a1 UID EXPUNGE 2:4\r\n".to_vec(),
"Invalid expunge command"
);
}
#[test]
fn check() {
let response = b"a1 OK CHECK completed\r\n".to_vec();