From b4d5cc60d8ea2ff400c274c6ece1139bc00686fc Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 10 Jan 2018 17:23:16 +0100 Subject: Inherit folder id (we can't hardcode it) --- tests/teststore.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/teststore.cpp b/tests/teststore.cpp index ef243b14..d57c9e07 100644 --- a/tests/teststore.cpp +++ b/tests/teststore.cpp @@ -47,7 +47,7 @@ static QStringList toStringList(const QVariantList &list) return s; } -static void createMail(const QVariantMap &object) +static void createMail(const QVariantMap &object, const QByteArray &folder = {}) { using namespace Sink::ApplicationDomain; @@ -71,6 +71,9 @@ static void createMail(const QVariantMap &object) auto mail = ApplicationDomainType::createEntity(object["resource"].toByteArray()); mail.setMimeMessage(msg->encodedContent(true)); + if (!folder.isEmpty()) { + mail.setFolder(folder); + } Sink::Store::create(mail).exec().waitForFinished(); } @@ -80,6 +83,10 @@ static void createFolder(const QVariantMap &object) auto folder = ApplicationDomainType::createEntity(object["resource"].toByteArray()); folder.setName(object["name"].toString()); Sink::Store::create(folder).exec().waitForFinished(); + + iterateOverObjects(object.value("mails").toList(), [=](const QVariantMap &object) { + createMail(object, folder.identifier()); + }); } void TestStore::setup(const QVariantMap &map) @@ -119,7 +126,9 @@ void TestStore::setup(const QVariantMap &map) }); iterateOverObjects(map.value("folders").toList(), createFolder); - iterateOverObjects(map.value("mails").toList(), createMail); + iterateOverObjects(map.value("mails").toList(), [] (const QVariantMap &map) { + createMail(map); + }); Sink::ResourceControl::flushMessageQueue(resources).exec().waitForFinished(); } -- cgit v1.2.3