diff options
author | Rémi Nicole <nicole@kolabsystems.com> | 2018-02-26 18:19:43 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-26 18:20:13 +0100 |
commit | 331f75d4da056ddb235be45a3784d2c19e545211 (patch) | |
tree | 64adc5432725e6d484012acfcea64b95b5d1711f /tests/teststore.cpp | |
parent | 2dc4d380f8c0cc90aa0dec67a826703c3ceb34af (diff) | |
download | kube-331f75d4da056ddb235be45a3784d2c19e545211.tar.gz kube-331f75d4da056ddb235be45a3784d2c19e545211.zip |
Improvements of the log view
Summary:
- Add a test view for the log view
- Allow passing the `entities` part of Sink messages
- That allowed getting information about which mail could not be sent in sink transmission errors
Reviewers: cmollekopf
Reviewed By: cmollekopf
Differential Revision: https://phabricator.kde.org/D10861
Diffstat (limited to 'tests/teststore.cpp')
-rw-r--r-- | tests/teststore.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/teststore.cpp b/tests/teststore.cpp index e5a3ea88..9d56dd33 100644 --- a/tests/teststore.cpp +++ b/tests/teststore.cpp | |||
@@ -160,11 +160,14 @@ QVariant TestStore::load(const QByteArray &type, const QVariantMap &filter) | |||
160 | using namespace Sink::ApplicationDomain; | 160 | using namespace Sink::ApplicationDomain; |
161 | const auto list = loadList(type, filter); | 161 | const auto list = loadList(type, filter); |
162 | if (!list.isEmpty()) { | 162 | if (!list.isEmpty()) { |
163 | if (list.size() > 1) { | ||
164 | qWarning() << "While loading" << type << "with filter" << filter | ||
165 | << "; got multiple elements, but returning the first one."; | ||
166 | } | ||
163 | return list.first(); | 167 | return list.first(); |
164 | } | 168 | } |
165 | return {}; | 169 | return {}; |
166 | } | 170 | } |
167 | |||
168 | template <typename T> | 171 | template <typename T> |
169 | QVariantList toVariantList(const QList<T> &list) | 172 | QVariantList toVariantList(const QList<T> &list) |
170 | { | 173 | { |
@@ -183,6 +186,17 @@ QVariantList TestStore::loadList(const QByteArray &type, const QVariantMap &filt | |||
183 | if (filter.contains("resource")) { | 186 | if (filter.contains("resource")) { |
184 | query.resourceFilter(filter.value("resource").toByteArray()); | 187 | query.resourceFilter(filter.value("resource").toByteArray()); |
185 | } | 188 | } |
189 | |||
190 | for (QVariantMap::const_iterator it = filter.begin(); it != filter.end(); ++it) { | ||
191 | if (it.key() == "messageId") { | ||
192 | query.filter<Mail::MessageId>(it.value()); | ||
193 | } else if (it.key() == "draft") { | ||
194 | query.filter<Mail::Draft>(it.value()); | ||
195 | } else if (it.key() == "subject") { | ||
196 | query.filter<Mail::Subject>(it.value()); | ||
197 | } | ||
198 | } | ||
199 | |||
186 | if (type == "mail") { | 200 | if (type == "mail") { |
187 | return toVariantList(Sink::Store::read<Mail>(query)); | 201 | return toVariantList(Sink::Store::read<Mail>(query)); |
188 | } | 202 | } |
@@ -205,6 +219,7 @@ QVariantMap TestStore::read(const QVariant &object) | |||
205 | using namespace Sink::ApplicationDomain; | 219 | using namespace Sink::ApplicationDomain; |
206 | QVariantMap map; | 220 | QVariantMap map; |
207 | if (auto mail = object.value<Mail::Ptr>()) { | 221 | if (auto mail = object.value<Mail::Ptr>()) { |
222 | map.insert("uid", mail->identifier()); | ||
208 | map.insert("subject", mail->getSubject()); | 223 | map.insert("subject", mail->getSubject()); |
209 | map.insert("draft", mail->getDraft()); | 224 | map.insert("draft", mail->getDraft()); |
210 | return map; | 225 | return map; |