use super::super::defs::*;
use super::extract_highest_modseq;
#[test]
fn condstore_search() {
let setup = set_up();
let mut client = setup.connect("7162cscs");
quick_log_in(&mut client);
quick_create(&mut client, "7162cscs");
quick_append_enron(&mut client, "7162cscs", 2);
command!(mut responses = client, c("SELECT 7162cscs (CONDSTORE)"));
assert_tagged_ok_any(responses.pop().unwrap());
let max_modseq = extract_highest_modseq(&responses);
ok_command!(client, c("STORE 1 +FLAGS (\\deleted)"));
command!(responses = client, c("NOOP"));
let new_modseq = extract_highest_modseq(&responses);
fn search_test(
client: &mut PipeClient,
command: &str,
expected_hits: &[u32],
expected_max_modseq: Option<u64>,
) {
command!(mut responses = client, cb(command));
assert_eq!(2, responses.len());
assert_tagged_ok(responses.pop().unwrap());
has_untagged_response_matching! {
s::Response::Search(ref sr) in responses => {
assert_eq!(expected_hits, &sr.hits[..]);
assert_eq!(expected_max_modseq, sr.max_modseq);
}
};
}
search_test(&mut client, "SEARCH MODSEQ 0", &[1, 2], Some(new_modseq));
search_test(
&mut client,
&format!("SEARCH MODSEQ {}", max_modseq),
&[1, 2],
Some(new_modseq),
);
search_test(
&mut client,
&format!("SEARCH MODSEQ {}", new_modseq),
&[1],
Some(new_modseq),
);
search_test(
&mut client,
&format!("SEARCH MODSEQ {}", new_modseq + 1),
&[],
None,
);
search_test(
&mut client,
&format!("SEARCH NOT MODSEQ {}", new_modseq),
&[2],
Some(max_modseq),
);
search_test(
&mut client,
&format!(r#"SEARCH MODSEQ "/flags/keyword" all {}"#, new_modseq),
&[1],
Some(new_modseq),
);
search_test(&mut client, "SEARCH DELETED", &[1], None);
}