summaryrefslogtreecommitdiffstats
path: root/tests/teststore.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-01-10 17:10:10 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-01-10 17:10:10 +0100
commit107e60448ec89883e60905f5a1cef507c0bf9fc2 (patch)
tree36fe3ba8226bb2bba594de8a3d574bfa2e28ce36 /tests/teststore.cpp
parent4e0369c1ca779576998c27dc4f06c018c5a22202 (diff)
downloadkube-107e60448ec89883e60905f5a1cef507c0bf9fc2.tar.gz
kube-107e60448ec89883e60905f5a1cef507c0bf9fc2.zip
Run views with a test dataset using TestStore.
This allows us to start the view using qmlscene with a testdata set that is created in a test datastore (isolated from the regular data).
Diffstat (limited to 'tests/teststore.cpp')
-rw-r--r--tests/teststore.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/teststore.cpp b/tests/teststore.cpp
index 728af885..ef243b14 100644
--- a/tests/teststore.cpp
+++ b/tests/teststore.cpp
@@ -71,11 +71,25 @@ 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 Sink::Store::create<Mail>(mail).exec().waitForFinished(); 74 Sink::Store::create(mail).exec().waitForFinished();
75}
76
77static void createFolder(const QVariantMap &object)
78{
79 using namespace Sink::ApplicationDomain;
80 auto folder = ApplicationDomainType::createEntity<Folder>(object["resource"].toByteArray());
81 folder.setName(object["name"].toString());
82 Sink::Store::create(folder).exec().waitForFinished();
75} 83}
76 84
77void TestStore::setup(const QVariantMap &map) 85void TestStore::setup(const QVariantMap &map)
78{ 86{
87 using namespace Sink::ApplicationDomain;
88 iterateOverObjects(map.value("accounts").toList(), [&] (const QVariantMap &object) {
89 auto account = ApplicationDomainType::createEntity<SinkAccount>("", object["id"].toByteArray());
90 account.setName(object["name"].toString());
91 Sink::Store::create(account).exec().waitForFinished();
92 });
79 QByteArrayList resources; 93 QByteArrayList resources;
80 iterateOverObjects(map.value("resources").toList(), [&] (const QVariantMap &object) { 94 iterateOverObjects(map.value("resources").toList(), [&] (const QVariantMap &object) {
81 resources << object["id"].toByteArray(); 95 resources << object["id"].toByteArray();
@@ -104,6 +118,7 @@ void TestStore::setup(const QVariantMap &map)
104 Sink::Store::create(identity).exec().waitForFinished(); 118 Sink::Store::create(identity).exec().waitForFinished();
105 }); 119 });
106 120
121 iterateOverObjects(map.value("folders").toList(), createFolder);
107 iterateOverObjects(map.value("mails").toList(), createMail); 122 iterateOverObjects(map.value("mails").toList(), createMail);
108 123
109 Sink::ResourceControl::flushMessageQueue(resources).exec().waitForFinished(); 124 Sink::ResourceControl::flushMessageQueue(resources).exec().waitForFinished();