diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-10 09:37:08 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-10 09:37:08 +0200 |
commit | e382924f1a90b5a27eba2e8c5981f6a4fe7892c9 (patch) | |
tree | 315780c4699be92d20121351bca4154c4fff8994 /tests/querytest.cpp | |
parent | f254153ac1571d5ab31a4f17fba2db9256bc24d3 (diff) | |
download | sink-e382924f1a90b5a27eba2e8c5981f6a4fe7892c9.tar.gz sink-e382924f1a90b5a27eba2e8c5981f6a4fe7892c9.zip |
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.
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
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: | |||
381 | { | 381 | { |
382 | // Setup | 382 | // Setup |
383 | Folder::Ptr folderEntity; | 383 | Folder::Ptr folderEntity; |
384 | const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); | ||
384 | { | 385 | { |
385 | Folder folder("sink.dummy.instance1"); | 386 | Folder folder("sink.dummy.instance1"); |
386 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); | 387 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); |
@@ -398,7 +399,6 @@ private slots: | |||
398 | folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Folder::Ptr>(); | 399 | folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Folder::Ptr>(); |
399 | QVERIFY(!folderEntity->identifier().isEmpty()); | 400 | QVERIFY(!folderEntity->identifier().isEmpty()); |
400 | 401 | ||
401 | const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); | ||
402 | { | 402 | { |
403 | Mail mail("sink.dummy.instance1"); | 403 | Mail mail("sink.dummy.instance1"); |
404 | mail.setExtractedMessageId("testSecond"); | 404 | mail.setExtractedMessageId("testSecond"); |
@@ -428,6 +428,11 @@ private slots: | |||
428 | query.filter<Mail::Folder>(*folderEntity); | 428 | query.filter<Mail::Folder>(*folderEntity); |
429 | query.sort<Mail::Date>(); | 429 | query.sort<Mail::Date>(); |
430 | query.limit(1); | 430 | query.limit(1); |
431 | query.setFlags(Query::LiveQuery); | ||
432 | query.reduce<ApplicationDomain::Mail::ThreadId>(Query::Reduce::Selector::max<ApplicationDomain::Mail::Date>()) | ||
433 | .count("count") | ||
434 | .collect<ApplicationDomain::Mail::Unread>("unreadCollected") | ||
435 | .collect<ApplicationDomain::Mail::Important>("importantCollected"); | ||
431 | 436 | ||
432 | // Ensure all local data is processed | 437 | // Ensure all local data is processed |
433 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); | 438 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
@@ -443,6 +448,26 @@ private slots: | |||
443 | QCOMPARE(model->rowCount(), 2); | 448 | QCOMPARE(model->rowCount(), 2); |
444 | // We can't make any assumptions about the order of the indexes | 449 | // We can't make any assumptions about the order of the indexes |
445 | // QCOMPARE(model->index(1, 0).data(Sink::Store::DomainObjectRole).value<Mail::Ptr>()->getProperty("messageId").toByteArray(), QByteArray("testSecond")); | 450 | // QCOMPARE(model->index(1, 0).data(Sink::Store::DomainObjectRole).value<Mail::Ptr>()->getProperty("messageId").toByteArray(), QByteArray("testSecond")); |
451 | |||
452 | //New revisions always go through | ||
453 | { | ||
454 | Mail mail("sink.dummy.instance1"); | ||
455 | mail.setExtractedMessageId("testInjected"); | ||
456 | mail.setFolder(folderEntity->identifier()); | ||
457 | mail.setExtractedDate(date.addDays(-2)); | ||
458 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | ||
459 | } | ||
460 | QTRY_COMPARE(model->rowCount(), 3); | ||
461 | |||
462 | //Ensure we can continue fetching after the incremental update | ||
463 | model->fetchMore(QModelIndex()); | ||
464 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | ||
465 | QCOMPARE(model->rowCount(), 4); | ||
466 | |||
467 | //Ensure we have fetched all | ||
468 | model->fetchMore(QModelIndex()); | ||
469 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | ||
470 | QCOMPARE(model->rowCount(), 4); | ||
446 | } | 471 | } |
447 | 472 | ||
448 | void testReactToNewResource() | 473 | void testReactToNewResource() |