From 1732482a4f9f4808c6f7cbbe985efc474f21ca0b Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Tue, 2 Aug 2022 10:47:23 +0200 Subject: [PATCH] Add test for MULTIAPPEND UIDPLUS response --- src/parse.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/parse.rs b/src/parse.rs index 060fdc2..c622a9d 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -754,4 +754,26 @@ mod tests { None => panic!("Missing UIDs in APPEND response"), }; } + + #[test] + fn parse_multiappend_uid() { + // If the user has enabled UIDPLUS (RFC 4315), the response contains an APPENDUID + // response code followed by the UIDVALIDITY of the destination mailbox and the + // UID assigned to the appended message in the destination mailbox. + // If the MULTIAPPEND extension is also used, there can be multiple UIDs. + let lines = b"A003 OK [APPENDUID 38505 3955:3957] APPEND completed\r\n"; + let (mut send, recv) = mpsc::channel(); + let resp = parse_append(lines, &mut send).unwrap(); + + assert!(recv.try_recv().is_err()); + assert_eq!(resp.uid_validity, Some(38505)); + match resp.uids { + Some(uid_list) => { + let mut it = uid_list.iter(); + assert_eq!(it.next(), Some(&UidSetMember::UidRange(3955..=3957))); + assert_eq!(it.next(), None); + } + None => panic!("Missing UIDs in APPEND response"), + }; + } }