summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/querytest.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index 7685086..f320d57 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -1008,6 +1008,53 @@ private slots:
1008 QTRY_COMPARE(model->rowCount(), 1); 1008 QTRY_COMPARE(model->rowCount(), 1);
1009 } 1009 }
1010 1010
1011 /*
1012 * Two messages in the same thread. The first get's filtered, the second one makes it.
1013 */
1014 void testFilteredReductionUpdateInSameThread()
1015 {
1016 // Setup
1017 auto folder1 = Folder::createEntity<Folder>("sink.dummy.instance1");
1018 VERIFYEXEC(Sink::Store::create<Folder>(folder1));
1019
1020 auto folder2 = Folder::createEntity<Folder>("sink.dummy.instance1");
1021 VERIFYEXEC(Sink::Store::create<Folder>(folder2));
1022
1023 // Ensure all local data is processed
1024 VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1"));
1025
1026 Query query;
1027 query.setId("testFilteredReductionUpdate");
1028 query.setFlags(Query::LiveQuery);
1029 query.filter<Mail::Folder>(folder1);
1030 query.reduce<Mail::MessageId>(Query::Reduce::Selector::max<Mail::Date>());
1031
1032 auto model = Sink::Store::loadModel<Mail>(query);
1033 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
1034 QCOMPARE(model->rowCount(), 0);
1035
1036 //The first message will be filtered (but would be aggreagted together with the message that passes)
1037 {
1038 auto mail = Mail::createEntity<Mail>("sink.dummy.instance1");
1039 mail.setExtractedMessageId("aggregatedId");
1040 mail.setFolder(folder2);
1041 VERIFYEXEC(Sink::Store::create(mail));
1042 }
1043
1044 VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1"));
1045 QCOMPARE(model->rowCount(), 0);
1046
1047 //Ensure the non-filtered still gets through.
1048 {
1049 auto mail = Mail::createEntity<Mail>("sink.dummy.instance1");
1050 mail.setExtractedMessageId("aggregatedId");
1051 mail.setFolder(folder1);
1052 VERIFYEXEC(Sink::Store::create(mail));
1053 }
1054 VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1"));
1055 QTRY_COMPARE(model->rowCount(), 1);
1056 }
1057
1011 void testBloom() 1058 void testBloom()
1012 { 1059 {
1013 // Setup 1060 // Setup