aboutsummaryrefslogtreecommitdiff
path: root/tests/common/fragments.rs
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2024-01-19 14:04:03 +0000
committerQuentin <quentin@dufour.io>2024-01-19 14:04:03 +0000
commit0f227e44e4996e54d2e55ed5c7a07f5458c4db4f (patch)
tree7f6c4fec623d0d99d3f09e752a360ca0f806429e /tests/common/fragments.rs
parent55e26d24a08519ded6a6898453dcd6db287f45c8 (diff)
parent23aa313e11f344da07143d60ce446b5f23d5f362 (diff)
downloadaerogramme-0f227e44e4996e54d2e55ed5c7a07f5458c4db4f.tar.gz
aerogramme-0f227e44e4996e54d2e55ed5c7a07f5458c4db4f.zip
Merge pull request 'Implement IDLE' (#72) from feat/idle into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/aerogramme/pulls/72
Diffstat (limited to 'tests/common/fragments.rs')
-rw-r--r--tests/common/fragments.rs31
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/common/fragments.rs b/tests/common/fragments.rs
index f9ad87e..7f7967a 100644
--- a/tests/common/fragments.rs
+++ b/tests/common/fragments.rs
@@ -36,6 +36,7 @@ pub enum Extension {
Move,
Condstore,
LiteralPlus,
+ Idle,
}
pub enum Enable {
@@ -114,6 +115,7 @@ pub fn capability(imap: &mut TcpStream, ext: Extension) -> Result<()> {
Extension::Move => Some("MOVE"),
Extension::Condstore => Some("CONDSTORE"),
Extension::LiteralPlus => Some("LITERAL+"),
+ Extension::Idle => Some("IDLE"),
};
let mut buffer: [u8; 6000] = [0; 6000];
@@ -286,7 +288,12 @@ pub fn noop_exists(imap: &mut TcpStream, must_exists: u32) -> Result<()> {
}
}
-pub fn fetch(imap: &mut TcpStream, selection: Selection, kind: FetchKind, modifier: FetchMod) -> Result<String> {
+pub fn fetch(
+ imap: &mut TcpStream,
+ selection: Selection,
+ kind: FetchKind,
+ modifier: FetchMod,
+) -> Result<String> {
let mut buffer: [u8; 65535] = [0; 65535];
let sel_str = match selection {
@@ -363,11 +370,11 @@ pub fn search(imap: &mut TcpStream, sk: SearchKind) -> Result<String> {
}
pub fn store(
- imap: &mut TcpStream,
- sel: Selection,
+ imap: &mut TcpStream,
+ sel: Selection,
flag: Flag,
action: StoreAction,
- modifier: StoreMod
+ modifier: StoreMod,
) -> Result<String> {
let mut buffer: [u8; 6000] = [0; 6000];
@@ -491,6 +498,22 @@ pub fn enable(imap: &mut TcpStream, ask: Enable, done: Option<Enable>) -> Result
Ok(())
}
+pub fn start_idle(imap: &mut TcpStream) -> Result<()> {
+ let mut buffer: [u8; 1500] = [0; 1500];
+ imap.write(&b"98 IDLE\r\n"[..])?;
+ let read = read_lines(imap, &mut buffer, None)?;
+ assert_eq!(read[0], b'+');
+ Ok(())
+}
+
+pub fn stop_idle(imap: &mut TcpStream) -> Result<String> {
+ let mut buffer: [u8; 16536] = [0; 16536];
+ imap.write(&b"DONE\r\n"[..])?;
+ let read = read_lines(imap, &mut buffer, Some(&b"98 OK"[..]))?;
+ let srv_msg = std::str::from_utf8(read)?;
+ Ok(srv_msg.to_string())
+}
+
pub fn logout(imap: &mut TcpStream) -> Result<()> {
imap.write(&b"99 logout\r\n"[..])?;
let mut buffer: [u8; 1500] = [0; 1500];