diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-03 00:06:51 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-03 00:06:51 +0100 |
commit | c1537e04e922bd8cb1d9a62670698d712ead657f (patch) | |
tree | e3476d020732f623793f1a4e8e29f703cf528fe9 /tests/querytest.cpp | |
parent | 39e055318b322e6b09782284109fc6748146fa26 (diff) | |
download | sink-c1537e04e922bd8cb1d9a62670698d712ead657f.tar.gz sink-c1537e04e922bd8cb1d9a62670698d712ead657f.zip |
React to removals in reduced live-query.
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 35 |
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 | ||
637 | QTEST_MAIN(QueryTest) | 672 | QTEST_MAIN(QueryTest) |