summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/accountstest.cpp64
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 8045f59..b25e7bc 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -54,6 +54,7 @@ auto_tests (
54 dummyresourcewritebenchmark 54 dummyresourcewritebenchmark
55 modelinteractivitytest 55 modelinteractivitytest
56 inspectiontest 56 inspectiontest
57 accountstest
57) 58)
58target_link_libraries(dummyresourcetest sink_resource_dummy) 59target_link_libraries(dummyresourcetest sink_resource_dummy)
59target_link_libraries(dummyresourcebenchmark sink_resource_dummy) 60target_link_libraries(dummyresourcebenchmark sink_resource_dummy)
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"