diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-11 04:24:34 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-11 04:24:34 +0200 |
commit | c4ae619718c4a3f2753331b1327855d2ea335634 (patch) | |
tree | db68264b03926c3b9c796eb899b638bb05bb6c41 /tests/querytest.cpp | |
parent | ef972138204a76680c4a69c9f467d3e22b53e62a (diff) | |
download | sink-c4ae619718c4a3f2753331b1327855d2ea335634.tar.gz sink-c4ae619718c4a3f2753331b1327855d2ea335634.zip |
Ensure subquery results work with live queries
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index e978787..c5c251a 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -529,6 +529,61 @@ private slots: | |||
529 | QCOMPARE(mails.first().getUid().toLatin1(), QByteArray("mail1")); | 529 | QCOMPARE(mails.first().getUid().toLatin1(), QByteArray("mail1")); |
530 | } | 530 | } |
531 | 531 | ||
532 | void testLiveSubquery() | ||
533 | { | ||
534 | // Setup | ||
535 | auto folder1 = Folder::createEntity<Folder>("sink.dummy.instance1"); | ||
536 | folder1.setSpecialPurpose(QByteArrayList() << "purpose1"); | ||
537 | VERIFYEXEC(Sink::Store::create<Folder>(folder1)); | ||
538 | |||
539 | auto folder2 = Folder::createEntity<Folder>("sink.dummy.instance1"); | ||
540 | folder2.setSpecialPurpose(QByteArrayList() << "purpose2"); | ||
541 | VERIFYEXEC(Sink::Store::create<Folder>(folder2)); | ||
542 | |||
543 | { | ||
544 | auto mail = Mail::createEntity<Mail>("sink.dummy.instance1"); | ||
545 | mail.setUid("mail1"); | ||
546 | mail.setFolder(folder1); | ||
547 | VERIFYEXEC(Sink::Store::create(mail)); | ||
548 | } | ||
549 | { | ||
550 | auto mail = Mail::createEntity<Mail>("sink.dummy.instance1"); | ||
551 | mail.setUid("mail2"); | ||
552 | mail.setFolder(folder2); | ||
553 | VERIFYEXEC(Sink::Store::create(mail)); | ||
554 | } | ||
555 | |||
556 | // Ensure all local data is processed | ||
557 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); | ||
558 | |||
559 | //Setup two folders with a mail each, ensure we only get the mail from the folder that matches the folder filter. | ||
560 | Query query; | ||
561 | query.filter<Mail::Folder>(Sink::Query().containsFilter<Folder::SpecialPurpose>("purpose1")); | ||
562 | query.request<Mail::Uid>(); | ||
563 | query.liveQuery = true; | ||
564 | |||
565 | auto model = Sink::Store::loadModel<Mail>(query); | ||
566 | QTRY_COMPARE(model->rowCount(), 1); | ||
567 | |||
568 | //This folder should not make it through the query | ||
569 | { | ||
570 | auto mail = Mail::createEntity<Mail>("sink.dummy.instance1"); | ||
571 | mail.setUid("mail3"); | ||
572 | mail.setFolder(folder2); | ||
573 | VERIFYEXEC(Sink::Store::create(mail)); | ||
574 | } | ||
575 | |||
576 | //But this one should | ||
577 | { | ||
578 | auto mail = Mail::createEntity<Mail>("sink.dummy.instance1"); | ||
579 | mail.setUid("mail4"); | ||
580 | mail.setFolder(folder1); | ||
581 | VERIFYEXEC(Sink::Store::create(mail)); | ||
582 | } | ||
583 | QTRY_COMPARE(model->rowCount(), 2); | ||
584 | |||
585 | } | ||
586 | |||
532 | void testResourceSubQuery() | 587 | void testResourceSubQuery() |
533 | { | 588 | { |
534 | using namespace Sink; | 589 | using namespace Sink; |