From c210d8c434d5fa8f6c56bbbdb0cb993ddd697213 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 7 Apr 2017 16:20:00 +0200 Subject: Avoid crashing if we fail to resolve the local id. --- tests/mailsynctest.cpp | 37 +++++++++++++++++++++++++++++++++++++ tests/mailsynctest.h | 2 ++ 2 files changed, 39 insertions(+) (limited to 'tests') diff --git a/tests/mailsynctest.cpp b/tests/mailsynctest.cpp index 3e5a928..c8ba9f1 100644 --- a/tests/mailsynctest.cpp +++ b/tests/mailsynctest.cpp @@ -411,6 +411,43 @@ void MailSyncTest::testSyncSingleFolder() } +void MailSyncTest::testSyncSingleMail() +{ + VERIFYEXEC(Store::synchronize(Sink::SyncScope{}.resourceFilter(mResourceInstanceIdentifier))); + VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); + + Mail::Ptr mail; + { + auto job = Store::fetchAll(Sink::Query{}.resourceFilter(mResourceInstanceIdentifier)).template then([&](const QList &mails) { + QVERIFY(mails.size() >= 1); + mail = mails.first(); + }); + VERIFYEXEC(job); + } + + auto syncScope = Sink::SyncScope{ApplicationDomain::getTypeName()}; + syncScope.resourceFilter(mResourceInstanceIdentifier); + syncScope.filter(mail->identifier()); + + // Ensure all local data is processed + VERIFYEXEC(Store::synchronize(syncScope)); + VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); +} + +void MailSyncTest::testSyncSingleMailWithBogusId() +{ + VERIFYEXEC(Store::synchronize(Sink::SyncScope{}.resourceFilter(mResourceInstanceIdentifier))); + VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); + + auto syncScope = Sink::SyncScope{ApplicationDomain::getTypeName()}; + syncScope.resourceFilter(mResourceInstanceIdentifier); + syncScope.filter("WTFisThisEven?"); + + // Ensure all local data is processed + VERIFYEXEC(Store::synchronize(syncScope)); + VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); +} + void MailSyncTest::testFailingSync() { auto resource = createFaultyResource(); diff --git a/tests/mailsynctest.h b/tests/mailsynctest.h index 8ad3bb3..0decf00 100644 --- a/tests/mailsynctest.h +++ b/tests/mailsynctest.h @@ -70,6 +70,8 @@ private slots: void testFlagChange(); void testSyncSingleFolder(); + void testSyncSingleMail(); + void testSyncSingleMailWithBogusId(); void testFailingSync(); }; -- cgit v1.2.3