From e382924f1a90b5a27eba2e8c5981f6a4fe7892c9 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 10 Jun 2017 09:37:08 +0200 Subject: Fixed incremental queries The incremental querying broke as soon as a revision update came in since it would nuke the base-set. This fixes it, but it's definitely not pretty. --- tests/querytest.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'tests/querytest.cpp') diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 4ff1be8..714e549 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -381,6 +381,7 @@ private slots: { // Setup Folder::Ptr folderEntity; + const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); { Folder folder("sink.dummy.instance1"); Sink::Store::create(folder).exec().waitForFinished(); @@ -398,7 +399,6 @@ private slots: folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value(); QVERIFY(!folderEntity->identifier().isEmpty()); - const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); { Mail mail("sink.dummy.instance1"); mail.setExtractedMessageId("testSecond"); @@ -428,6 +428,11 @@ private slots: query.filter(*folderEntity); query.sort(); query.limit(1); + query.setFlags(Query::LiveQuery); + query.reduce(Query::Reduce::Selector::max()) + .count("count") + .collect("unreadCollected") + .collect("importantCollected"); // Ensure all local data is processed VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); @@ -443,6 +448,26 @@ private slots: QCOMPARE(model->rowCount(), 2); // We can't make any assumptions about the order of the indexes // QCOMPARE(model->index(1, 0).data(Sink::Store::DomainObjectRole).value()->getProperty("messageId").toByteArray(), QByteArray("testSecond")); + + //New revisions always go through + { + Mail mail("sink.dummy.instance1"); + mail.setExtractedMessageId("testInjected"); + mail.setFolder(folderEntity->identifier()); + mail.setExtractedDate(date.addDays(-2)); + Sink::Store::create(mail).exec().waitForFinished(); + } + QTRY_COMPARE(model->rowCount(), 3); + + //Ensure we can continue fetching after the incremental update + model->fetchMore(QModelIndex()); + QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); + QCOMPARE(model->rowCount(), 4); + + //Ensure we have fetched all + model->fetchMore(QModelIndex()); + QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); + QCOMPARE(model->rowCount(), 4); } void testReactToNewResource() -- cgit v1.2.3