summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-07 16:20:00 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-07 16:20:00 +0200
commitc210d8c434d5fa8f6c56bbbdb0cb993ddd697213 (patch)
treef3f62d8b6ff8665605d3c22997c0e58f233f20c9 /tests
parent41c69690d866414cf90d603629fd488ba9a981b5 (diff)
downloadsink-c210d8c434d5fa8f6c56bbbdb0cb993ddd697213.tar.gz
sink-c210d8c434d5fa8f6c56bbbdb0cb993ddd697213.zip
Avoid crashing if we fail to resolve the local id.
Diffstat (limited to 'tests')
-rw-r--r--tests/mailsynctest.cpp37
-rw-r--r--tests/mailsynctest.h2
2 files changed, 39 insertions, 0 deletions
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()
411 411
412} 412}
413 413
414void MailSyncTest::testSyncSingleMail()
415{
416 VERIFYEXEC(Store::synchronize(Sink::SyncScope{}.resourceFilter(mResourceInstanceIdentifier)));
417 VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier));
418
419 Mail::Ptr mail;
420 {
421 auto job = Store::fetchAll<Mail>(Sink::Query{}.resourceFilter(mResourceInstanceIdentifier)).template then([&](const QList<Mail::Ptr> &mails) {
422 QVERIFY(mails.size() >= 1);
423 mail = mails.first();
424 });
425 VERIFYEXEC(job);
426 }
427
428 auto syncScope = Sink::SyncScope{ApplicationDomain::getTypeName<Mail>()};
429 syncScope.resourceFilter(mResourceInstanceIdentifier);
430 syncScope.filter(mail->identifier());
431
432 // Ensure all local data is processed
433 VERIFYEXEC(Store::synchronize(syncScope));
434 VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier));
435}
436
437void MailSyncTest::testSyncSingleMailWithBogusId()
438{
439 VERIFYEXEC(Store::synchronize(Sink::SyncScope{}.resourceFilter(mResourceInstanceIdentifier)));
440 VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier));
441
442 auto syncScope = Sink::SyncScope{ApplicationDomain::getTypeName<Mail>()};
443 syncScope.resourceFilter(mResourceInstanceIdentifier);
444 syncScope.filter("WTFisThisEven?");
445
446 // Ensure all local data is processed
447 VERIFYEXEC(Store::synchronize(syncScope));
448 VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier));
449}
450
414void MailSyncTest::testFailingSync() 451void MailSyncTest::testFailingSync()
415{ 452{
416 auto resource = createFaultyResource(); 453 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:
70 void testFlagChange(); 70 void testFlagChange();
71 71
72 void testSyncSingleFolder(); 72 void testSyncSingleFolder();
73 void testSyncSingleMail();
74 void testSyncSingleMailWithBogusId();
73 75
74 void testFailingSync(); 76 void testFailingSync();
75}; 77};