summaryrefslogtreecommitdiffstats
path: root/tests/querytest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-03 00:06:51 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-03 00:06:51 +0100
commitc1537e04e922bd8cb1d9a62670698d712ead657f (patch)
treee3476d020732f623793f1a4e8e29f703cf528fe9 /tests/querytest.cpp
parent39e055318b322e6b09782284109fc6748146fa26 (diff)
downloadsink-c1537e04e922bd8cb1d9a62670698d712ead657f.tar.gz
sink-c1537e04e922bd8cb1d9a62670698d712ead657f.zip
React to removals in reduced live-query.
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r--tests/querytest.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index 574e68d..46181a6 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -632,6 +632,41 @@ private slots:
632 auto folders = Sink::Store::read<Folder>(query); 632 auto folders = Sink::Store::read<Folder>(query);
633 QCOMPARE(folders.size(), 1); 633 QCOMPARE(folders.size(), 1);
634 } 634 }
635 void testLivequeryUnmatchInThread()
636 {
637 // Setup
638 auto folder1 = Folder::createEntity<Folder>("sink.dummy.instance1");
639 VERIFYEXEC(Sink::Store::create<Folder>(folder1));
640
641 auto folder2 = Folder::createEntity<Folder>("sink.dummy.instance1");
642 VERIFYEXEC(Sink::Store::create<Folder>(folder2));
643
644 auto mail1 = Mail::createEntity<Mail>("sink.dummy.instance1");
645 mail1.setUid("mail1");
646 mail1.setFolder(folder1);
647 VERIFYEXEC(Sink::Store::create(mail1));
648 // Ensure all local data is processed
649 VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1"));
650
651 //Setup two folders with a mail each, ensure we only get the mail from the folder that matches the folder filter.
652 Query query;
653 query.setId("testLivequeryUnmatch");
654 query.filter<Mail::Folder>(folder1);
655 query.reduce<Mail::ThreadId>(Query::Reduce::Selector::max<Mail::Date>()).count("count").collect<Mail::Sender>("senders");
656 query.sort<Mail::Date>();
657 query.setFlags(Query::LiveQuery);
658 auto model = Sink::Store::loadModel<Mail>(query);
659 QTRY_COMPARE(model->rowCount(), 1);
660
661 //After the modifcation the mail should have vanished.
662 {
663
664 mail1.setFolder(folder2);
665 VERIFYEXEC(Sink::Store::modify(mail1));
666 }
667 VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1"));
668 QTRY_COMPARE(model->rowCount(), 0);
669 }
635}; 670};
636 671
637QTEST_MAIN(QueryTest) 672QTEST_MAIN(QueryTest)