1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
use std::sync::Arc;
use fixtures::{NotmuchCommand, MailBox};
struct QueryFixture {
// Return a single thread with 2 messages
pub mailbox: MailBox,
pub query: notmuch::Query<'static>,
}
impl QueryFixture {
pub fn new() -> Self{
let mailbox = MailBox::new();
let (msgid, _) = mailbox.deliver(None, Some("foo".to_string()), None, None, vec![], true, None, false, false, false).unwrap();
mailbox.deliver(None, Some("bar".to_string()), None, None, vec![], true, None, false, false, false).unwrap();
mailbox.deliver(None, Some("baz".to_string()), None, None, vec![("In-Reply-To".to_string(), format!("<{}>", msgid))], true, None, false, false, false).unwrap();
mailbox.deliver(None, Some("foo qux".to_string()), None, None, vec![], true, None, false, false, false).unwrap();
mailbox.deliver(None, Some("foo quux".to_string()), None, None, vec![], true, None, false, false, false).unwrap();
let cmd = NotmuchCommand::new(&mailbox.path());
cmd.run(vec!["new"]).unwrap();
let query = {
let database = Arc::new(notmuch::Database::open(&mailbox.path(), notmuch::DatabaseMode::ReadWrite).unwrap());
notmuch::Query::create(database, &"foo".to_string()).unwrap()
};
Self {
mailbox,
query
}
}
}
#[test]
fn test_iter_threads() {
let q = QueryFixture::new();
let threads = q.query.search_threads().unwrap();
let mut num = 0;
for _thread in threads {
num += 1;
}
assert_eq!(num, 3);
}
#[test]
fn test_iter_threads_ext() {
let q = QueryFixture::new();
let threads = <notmuch::Query as notmuch::QueryExt>::search_threads(q.query).unwrap();
let mut num = 0;
for _thread in threads {
num += 1;
}
assert_eq!(num, 3);
}
#[test]
fn test_iter_messages() {
let q = QueryFixture::new();
let messages = q.query.search_messages().unwrap();
let mut num = 0;
for _message in messages {
num += 1;
}
assert_eq!(num, 3);
}
#[test]
fn test_iter_messages_ext() {
let q = QueryFixture::new();
let messages = <notmuch::Query as notmuch::QueryExt>::search_messages(q.query).unwrap();
let mut num = 0;
for _message in messages {
num += 1;
}
assert_eq!(num, 3);
}
|