From e79c0ae5b7b6202be5206310eebb2891e162f396 Mon Sep 17 00:00:00 2001 From: Todd Mortimer Date: Sat, 24 Apr 2021 19:52:35 -0400 Subject: [PATCH] Add test for dovecot unsolicited OK progress message. --- src/parse.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/parse.rs b/src/parse.rs index 7a026c2b..8a2a1cc3 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -504,6 +504,28 @@ mod tests { assert_eq!(fetches[0].uid, Some(74)); } + #[test] + fn parse_fetches_w_dovecot_info() { + // Dovecot will sometimes send informational unsolicited + // OK messages while performing long operations. + // * OK Searched 91% of the mailbox, ETA 0:01 + let lines = b"\ + * OK Searched 91% of the mailbox, ETA 0:01\r\n\ + * 37 FETCH (UID 74)\r\n"; + let (mut send, recv) = mpsc::channel(); + let fetches = parse_fetches(lines.to_vec(), &mut send).unwrap(); + assert_eq!( + recv.try_recv(), + Ok(UnsolicitedResponse::Ok { + code: None, + information: Some(String::from("Searched 91% of the mailbox, ETA 0:01")), + }) + ); + assert_eq!(fetches.len(), 1); + assert_eq!(fetches[0].message, 37); + assert_eq!(fetches[0].uid, Some(74)); + } + #[test] fn parse_names_w_unilateral() { let lines = b"\