summaryrefslogtreecommitdiffstats
path: root/tests/querytest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-02-09 15:17:54 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-02-13 19:42:38 +0100
commita372d9cc6c950beb401aef9005f97faeaf95b804 (patch)
treeb5ee62d5c554cf613c3bbb720bf2ee49b41d9026 /tests/querytest.cpp
parent516d38bd7bca5562ebb7b21b96a5dd62152ee52e (diff)
downloadsink-a372d9cc6c950beb401aef9005f97faeaf95b804.tar.gz
sink-a372d9cc6c950beb401aef9005f97faeaf95b804.zip
Fixed query flags.
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r--tests/querytest.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index 0d3ffc3..0641c0d 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -670,6 +670,46 @@ private slots:
670 QTRY_COMPARE(model->rowCount(), 0); 670 QTRY_COMPARE(model->rowCount(), 0);
671 } 671 }
672 672
673 void testDontUpdateNonLiveQuery()
674 {
675 // Setup
676 auto folder1 = Folder::createEntity<Folder>("sink.dummy.instance1");
677 VERIFYEXEC(Sink::Store::create<Folder>(folder1));
678
679 auto mail1 = Mail::createEntity<Mail>("sink.dummy.instance1");
680 mail1.setExtractedMessageId("mail1");
681 mail1.setFolder(folder1);
682 mail1.setUnread(false);
683 VERIFYEXEC(Sink::Store::create(mail1));
684
685 // Ensure all local data is processed
686 VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1"));
687
688 Query query;
689 //Not a live query
690 query.setFlags(Query::Flags{});
691 query.setId("testNoLiveQuery");
692 query.filter<Mail::Folder>(folder1);
693 query.reduce<Mail::ThreadId>(Query::Reduce::Selector::max<Mail::Date>()).count("count").collect<Mail::Sender>("senders");
694 query.sort<Mail::Date>();
695 query.request<Mail::Unread>();
696 QVERIFY(!query.liveQuery());
697
698 auto model = Sink::Store::loadModel<Mail>(query);
699 QTRY_COMPARE(model->rowCount(), 1);
700
701 //After the modifcation the mail should have vanished.
702 {
703 mail1.setUnread(true);
704 VERIFYEXEC(Sink::Store::modify(mail1));
705 }
706 VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1"));
707 QTRY_COMPARE(model->rowCount(), 1);
708 auto mail = model->data(model->index(0, 0, QModelIndex{}), Sink::Store::DomainObjectRole).value<Mail::Ptr>();
709 QTest::qWait(100);
710 QCOMPARE(mail->getUnread(), false);
711 }
712
673 void testLivequeryModifcationUpdateInThread() 713 void testLivequeryModifcationUpdateInThread()
674 { 714 {
675 // Setup 715 // Setup