Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: Add UID EXPUNGE support #87

Merged
merged 2 commits into from
Oct 8, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(),
mtorromeo marked this conversation as resolved.
Show resolved Hide resolved
"Invalid expunge command"
);
}

#[test]
fn check() {
let response = b"a1 OK CHECK completed\r\n".to_vec();
Expand Down