aboutsummaryrefslogtreecommitdiff
path: root/tests/common/fragments.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-04 11:51:14 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-04 11:51:14 +0100
commita93967a6f8f1c881c64879e61edc46d64c4c662e (patch)
treeeaeb891d82d30079d919e2b3faa82f9c711e66c3 /tests/common/fragments.rs
parenta0a7dd0ed6afac48c5d5c0b149efb8288d03e115 (diff)
downloadaerogramme-a93967a6f8f1c881c64879e61edc46d64c4c662e.tar.gz
aerogramme-a93967a6f8f1c881c64879e61edc46d64c4c662e.zip
create a single behavior test with all files
Diffstat (limited to 'tests/common/fragments.rs')
-rw-r--r--tests/common/fragments.rs31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/common/fragments.rs b/tests/common/fragments.rs
index 530f1f7..c8d5ef1 100644
--- a/tests/common/fragments.rs
+++ b/tests/common/fragments.rs
@@ -11,7 +11,11 @@ use crate::common::*;
/// arbitrary values, only enum for which the code is known
/// to be correct. The idea is that the generated message is more
/// or less hardcoded by the developer, so its clear what's expected,
-/// and not generated by a library.
+/// and not generated by a library. Also don't use vector of enum,
+/// as it again introduce some kind of genericity we try so hard to avoid:
+/// instead add a dedicated enum, for example "All" or anything relaevent that would
+/// describe your list and then hardcode it in your fragment.
+/// DON'T. TRY. TO. BE. GENERIC. HERE.
pub fn connect(imap: &mut TcpStream) -> Result<()> {
let mut buffer: [u8; 1500] = [0; 1500];
@@ -33,6 +37,12 @@ pub enum Extension {
CondStore,
}
+pub enum Enable {
+ Utf8Accept,
+ CondStore,
+ All,
+}
+
pub enum Mailbox {
Inbox,
Archive,
@@ -357,6 +367,25 @@ pub fn r#move(imap: &mut TcpStream, selection: Selection, to: Mailbox) -> Result
Ok(())
}
+pub fn enable(imap: &mut TcpStream, ask: Enable, done: Option<Enable>) -> Result<()> {
+ let mut buffer: [u8; 6000] = [0; 6000];
+ assert!(matches!(ask, Enable::Utf8Accept));
+
+ imap.write(&b"36 enable UTF8=ACCEPT\r\n"[..])?;
+ let read = read_lines(imap, &mut buffer, Some(&b"36 OK"[..]))?;
+ let srv_msg = std::str::from_utf8(read)?;
+ match done {
+ None => assert_eq!(srv_msg.lines().count(), 1),
+ Some(Enable::Utf8Accept) => {
+ assert_eq!(srv_msg.lines().count(), 2);
+ assert!(srv_msg.contains("* ENABLED UTF8=ACCEPT"));
+ },
+ _ => unimplemented!(),
+ }
+
+ Ok(())
+}
+
pub fn logout(imap: &mut TcpStream) -> Result<()> {
imap.write(&b"99 logout\r\n"[..])?;
let mut buffer: [u8; 1500] = [0; 1500];