diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-10 17:23:16 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-10 17:23:16 +0100 |
commit | b4d5cc60d8ea2ff400c274c6ece1139bc00686fc (patch) | |
tree | 1001917c68cc05d0aa7ee9a863bf2b0c5ea1769f /tests/teststore.cpp | |
parent | 107e60448ec89883e60905f5a1cef507c0bf9fc2 (diff) | |
download | kube-b4d5cc60d8ea2ff400c274c6ece1139bc00686fc.tar.gz kube-b4d5cc60d8ea2ff400c274c6ece1139bc00686fc.zip |
Inherit folder id (we can't hardcode it)
Diffstat (limited to 'tests/teststore.cpp')
-rw-r--r-- | tests/teststore.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
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) | |||
47 | return s; | 47 | return s; |
48 | } | 48 | } |
49 | 49 | ||
50 | static void createMail(const QVariantMap &object) | 50 | static void createMail(const QVariantMap &object, const QByteArray &folder = {}) |
51 | { | 51 | { |
52 | using namespace Sink::ApplicationDomain; | 52 | using namespace Sink::ApplicationDomain; |
53 | 53 | ||
@@ -71,6 +71,9 @@ static void createMail(const QVariantMap &object) | |||
71 | 71 | ||
72 | auto mail = ApplicationDomainType::createEntity<Mail>(object["resource"].toByteArray()); | 72 | auto mail = ApplicationDomainType::createEntity<Mail>(object["resource"].toByteArray()); |
73 | mail.setMimeMessage(msg->encodedContent(true)); | 73 | mail.setMimeMessage(msg->encodedContent(true)); |
74 | if (!folder.isEmpty()) { | ||
75 | mail.setFolder(folder); | ||
76 | } | ||
74 | Sink::Store::create(mail).exec().waitForFinished(); | 77 | Sink::Store::create(mail).exec().waitForFinished(); |
75 | } | 78 | } |
76 | 79 | ||
@@ -80,6 +83,10 @@ static void createFolder(const QVariantMap &object) | |||
80 | auto folder = ApplicationDomainType::createEntity<Folder>(object["resource"].toByteArray()); | 83 | auto folder = ApplicationDomainType::createEntity<Folder>(object["resource"].toByteArray()); |
81 | folder.setName(object["name"].toString()); | 84 | folder.setName(object["name"].toString()); |
82 | Sink::Store::create(folder).exec().waitForFinished(); | 85 | Sink::Store::create(folder).exec().waitForFinished(); |
86 | |||
87 | iterateOverObjects(object.value("mails").toList(), [=](const QVariantMap &object) { | ||
88 | createMail(object, folder.identifier()); | ||
89 | }); | ||
83 | } | 90 | } |
84 | 91 | ||
85 | void TestStore::setup(const QVariantMap &map) | 92 | void TestStore::setup(const QVariantMap &map) |
@@ -119,7 +126,9 @@ void TestStore::setup(const QVariantMap &map) | |||
119 | }); | 126 | }); |
120 | 127 | ||
121 | iterateOverObjects(map.value("folders").toList(), createFolder); | 128 | iterateOverObjects(map.value("folders").toList(), createFolder); |
122 | iterateOverObjects(map.value("mails").toList(), createMail); | 129 | iterateOverObjects(map.value("mails").toList(), [] (const QVariantMap &map) { |
130 | createMail(map); | ||
131 | }); | ||
123 | 132 | ||
124 | Sink::ResourceControl::flushMessageQueue(resources).exec().waitForFinished(); | 133 | Sink::ResourceControl::flushMessageQueue(resources).exec().waitForFinished(); |
125 | } | 134 | } |