use std::borrow::Cow;
use super::defs::*;
#[test]
fn capability_declared() {
test_require_capability("5819capa", "LIST-STATUS");
}
#[test]
fn test_list_status() {
let setup = set_up();
let mut client = setup.connect("5819lsst");
quick_log_in(&mut client);
quick_create(&mut client, "5819lsst/foo");
quick_create(&mut client, "5819lsst/noselect/bar");
quick_append_enron(&mut client, "5819lsst/foo", 2);
quick_append_enron(&mut client, "5819lsst/noselect/bar", 3);
ok_command!(client, c("DELETE 5819lsst/noselect"));
command!(
responses = client,
c("LIST 5819lsst/ * RETURN (STATUS (RECENT UIDNEXT))")
);
assert_eq!(6, responses.len());
let mut responses = responses.into_iter();
match responses.next().unwrap() {
s::ResponseLine {
tag: None,
response: s::Response::List(lr),
} => assert_eq!("5819lsst/foo", lr.name.raw),
r => panic!("Unexpected response: {:?}", r),
}
match responses.next().unwrap() {
s::ResponseLine {
tag: None,
response: s::Response::Status(sr),
} => {
assert_eq!("5819lsst/foo", sr.mailbox.raw);
assert!(sr.atts.contains(&s::StatusResponseAtt::Recent(2)));
assert!(sr.atts.contains(&s::StatusResponseAtt::UidNext(3)));
}
r => panic!("Unexpected response: {:?}", r),
}
match responses.next().unwrap() {
s::ResponseLine {
tag: None,
response: s::Response::List(lr),
} => {
assert_eq!("5819lsst/noselect", lr.name.raw);
assert!(lr.flags.contains(&Cow::Borrowed("\\Noselect")));
}
r => panic!("Unexpected response: {:?}", r),
}
match responses.next().unwrap() {
s::ResponseLine {
tag: None,
response: s::Response::List(lr),
} => assert_eq!("5819lsst/noselect/bar", lr.name.raw),
r => panic!("Unexpected response: {:?}", r),
}
match responses.next().unwrap() {
s::ResponseLine {
tag: None,
response: s::Response::Status(sr),
} => {
assert_eq!("5819lsst/noselect/bar", sr.mailbox.raw);
assert!(sr.atts.contains(&s::StatusResponseAtt::Recent(3)));
assert!(sr.atts.contains(&s::StatusResponseAtt::UidNext(4)));
}
r => panic!("Unexpected response: {:?}", r),
}
assert_tagged_ok(responses.next().unwrap());
assert_bad_command(
&mut client,
Some(s::RespTextCode::ClientBug(())),
"LIST \"\" * RETURN (STATUS (RECENT) STATUS (UNSEEN))",
);
}