summaryrefslogtreecommitdiffstats
path: root/tests/accountstest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-04-10 22:33:57 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-04-10 22:33:57 +0200
commit9f5e4a488360c2c0232a12b65e9d1c8366c0bc8b (patch)
tree20e35a0ba6d6c2ab1a7b304902a1205eb61547cb /tests/accountstest.cpp
parent161bc918e745801bcf7fa5a9f504c721aab08258 (diff)
downloadsink-9f5e4a488360c2c0232a12b65e9d1c8366c0bc8b.tar.gz
sink-9f5e4a488360c2c0232a12b65e9d1c8366c0bc8b.zip
accountstest and a way to create new entities
Diffstat (limited to 'tests/accountstest.cpp')
-rw-r--r--tests/accountstest.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp
new file mode 100644
index 0000000..0ae10ec
--- /dev/null
+++ b/tests/accountstest.cpp
@@ -0,0 +1,64 @@
1#include <QTest>
2#include <QDebug>
3#include <QSignalSpy>
4#include <functional>
5
6#include <test.h>
7#include <store.h>
8
9class AccountsTest : public QObject
10{
11 Q_OBJECT
12private slots:
13
14 void initTestCase()
15 {
16 Sink::Test::initTest();
17 }
18
19 void testLoad()
20 {
21 using namespace Sink;
22 using namespace Sink::ApplicationDomain;
23
24 QString accountName("name");
25 QString accountIcon("icon");
26 auto account = ApplicationDomainType::createEntity<SinkAccount>();
27 account.setProperty("type", "maildir");
28 account.setProperty("name", accountName);
29 account.setProperty("icon", accountIcon);
30 Store::create(account).exec().waitForFinished();
31
32 Store::fetchAll<SinkAccount>(Query()).then<void, QList<SinkAccount>>([](const QList<SinkAccount> &accounts) {
33 QCOMPARE(accounts.size(), 1);
34 })
35 .exec().waitForFinished();
36
37 QString smtpServer("smtpServer");
38 QString smtpUsername("smtpUsername");
39 QString smtpPassword("smtpPassword");
40 auto resource = ApplicationDomainType::createEntity<SinkResource>();
41 resource.setProperty("type", "org.kde.mailtransport");
42 resource.setProperty("account", account.identifier());
43 resource.setProperty("server", smtpServer);
44 resource.setProperty("username", smtpUsername);
45 resource.setProperty("password", smtpPassword);
46 Store::create(resource).exec().waitForFinished();
47
48
49 Store::fetchAll<SinkResource>(Query()).then<void, QList<SinkResource>>([](const QList<SinkResource> &resources) {
50 QCOMPARE(resources.size(), 1);
51 })
52 .exec().waitForFinished();
53
54 Store::remove(resource).exec().waitForFinished();
55
56 Store::fetchAll<SinkResource>(Query()).then<void, QList<SinkResource>>([](const QList<SinkResource> &resources) {
57 QCOMPARE(resources.size(), 0);
58 })
59 .exec().waitForFinished();
60 }
61};
62
63QTEST_GUILESS_MAIN(AccountsTest)
64#include "accountstest.moc"