diff options
Diffstat (limited to 'tests/mailthreadtest.cpp')
-rw-r--r-- | tests/mailthreadtest.cpp | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/tests/mailthreadtest.cpp b/tests/mailthreadtest.cpp index e9fe499..6ba54df 100644 --- a/tests/mailthreadtest.cpp +++ b/tests/mailthreadtest.cpp | |||
@@ -75,11 +75,9 @@ void MailThreadTest::testListThreadLeader() | |||
75 | VERIFYEXEC(Store::synchronize(query)); | 75 | VERIFYEXEC(Store::synchronize(query)); |
76 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 76 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
77 | 77 | ||
78 | auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { | 78 | auto mails = Store::read<Mail>(query); |
79 | QCOMPARE(mails.size(), 1); | 79 | QCOMPARE(mails.size(), 1); |
80 | QVERIFY(mails.first()->getSubject().startsWith(QString("ThreadLeader"))); | 80 | QVERIFY(mails.first().getSubject().startsWith(QString("ThreadLeader"))); |
81 | }); | ||
82 | VERIFYEXEC(job); | ||
83 | } | 81 | } |
84 | 82 | ||
85 | /* | 83 | /* |
@@ -126,25 +124,19 @@ void MailThreadTest::testIndexInMixedOrder() | |||
126 | } | 124 | } |
127 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | 125 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
128 | 126 | ||
129 | Sink::Query query; | 127 | auto query = Sink::Query::threadLeaders(folder); |
130 | query.filter(SinkResource(mResourceInstanceIdentifier)); | 128 | query.filter(SinkResource(mResourceInstanceIdentifier)); |
131 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); | 129 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); |
132 | query.filter<Mail::Folder>(folder); | ||
133 | query.sort<Mail::Date>(); | ||
134 | query.reduce<Mail::ThreadId>(Query::Reduce::Selector::max<Mail::Date>()); | ||
135 | 130 | ||
136 | Mail threadLeader; | 131 | Mail threadLeader; |
137 | 132 | ||
138 | //Ensure we find the thread leader | 133 | //Ensure we find the thread leader |
139 | { | 134 | { |
140 | auto job = Store::fetchAll<Mail>(query) | 135 | auto mails = Store::read<Mail>(query); |
141 | .syncThen<void, QList<Mail::Ptr>>([=, &threadLeader](const QList<Mail::Ptr> &mails) { | 136 | QCOMPARE(mails.size(), 1); |
142 | QCOMPARE(mails.size(), 1); | 137 | auto mail = mails.first(); |
143 | auto mail = *mails.first(); | 138 | threadLeader = mail; |
144 | threadLeader = mail; | 139 | QCOMPARE(mail.getSubject(), QString::fromLatin1("Re: Re: 1")); |
145 | QCOMPARE(mail.getSubject(), QString::fromLatin1("Re: Re: 1")); | ||
146 | }); | ||
147 | VERIFYEXEC(job); | ||
148 | } | 140 | } |
149 | 141 | ||
150 | { | 142 | { |
@@ -157,13 +149,10 @@ void MailThreadTest::testIndexInMixedOrder() | |||
157 | 149 | ||
158 | //Ensure we find the thread leader still | 150 | //Ensure we find the thread leader still |
159 | { | 151 | { |
160 | auto job = Store::fetchAll<Mail>(query) | 152 | auto mails = Store::read<Mail>(query); |
161 | .syncThen<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) { | 153 | QCOMPARE(mails.size(), 1); |
162 | QCOMPARE(mails.size(), 1); | 154 | auto mail = mails.first(); |
163 | auto mail = *mails.first(); | 155 | QCOMPARE(mail.getSubject(), QString::fromLatin1("Re: Re: 1")); |
164 | QCOMPARE(mail.getSubject(), QString::fromLatin1("Re: Re: 1")); | ||
165 | }); | ||
166 | VERIFYEXEC(job); | ||
167 | } | 156 | } |
168 | 157 | ||
169 | { | 158 | { |
@@ -176,20 +165,13 @@ void MailThreadTest::testIndexInMixedOrder() | |||
176 | 165 | ||
177 | //Ensure the thread is complete | 166 | //Ensure the thread is complete |
178 | { | 167 | { |
179 | Sink::Query query; | 168 | auto query = Sink::Query::completeThread(threadLeader); |
180 | query.filter(SinkResource(mResourceInstanceIdentifier)); | ||
181 | query.ids << threadLeader.identifier(); | ||
182 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); | 169 | query.request<Mail::Subject>().request<Mail::MimeMessage>().request<Mail::Folder>().request<Mail::Date>(); |
183 | query.sort<Mail::Date>(); | 170 | |
184 | query.bloom<Mail::ThreadId>(); | 171 | auto mails = Store::read<Mail>(query); |
185 | 172 | QCOMPARE(mails.size(), 3); | |
186 | auto job = Store::fetchAll<Mail>(query) | 173 | auto mail = mails.first(); |
187 | .syncThen<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) { | 174 | QCOMPARE(mail.getSubject(), QString::fromLatin1("Re: Re: 1")); |
188 | QCOMPARE(mails.size(), 3); | ||
189 | auto mail = *mails.first(); | ||
190 | QCOMPARE(mail.getSubject(), QString::fromLatin1("Re: Re: 1")); | ||
191 | }); | ||
192 | VERIFYEXEC(job); | ||
193 | } | 175 | } |
194 | 176 | ||
195 | /* VERIFYEXEC(Store::remove(mail)); */ | 177 | /* VERIFYEXEC(Store::remove(mail)); */ |