summaryrefslogtreecommitdiffstats
path: root/tests/dummyresourcefacadetest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dummyresourcefacadetest.cpp')
-rw-r--r--tests/dummyresourcefacadetest.cpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/tests/dummyresourcefacadetest.cpp b/tests/dummyresourcefacadetest.cpp
deleted file mode 100644
index e4d27fc..0000000
--- a/tests/dummyresourcefacadetest.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
1#include <QtTest>
2
3#include <iostream>
4
5#include <QDebug>
6#include <QString>
7#include <QtConcurrent/QtConcurrentRun>
8
9#include "common/storage.h"
10#include "dummyresource/facade.h"
11
12class DummyResourceFacadeTest : public QObject
13{
14 Q_OBJECT
15private:
16 QString testDataPath;
17 QString dbName;
18 const char *keyPrefix = "key";
19
20 void populate(int count)
21 {
22 Akonadi2::Storage storage(testDataPath, dbName, Akonadi2::Storage::ReadWrite);
23 for (int i = 0; i < count; i++) {
24 storage.write(keyPrefix + std::to_string(i), keyPrefix + std::to_string(i));
25 }
26 storage.commitTransaction();
27 }
28
29private Q_SLOTS:
30 void initTestCase()
31 {
32 testDataPath = Akonadi2::Store::storageLocation();
33 dbName = "dummyresource";
34 Akonadi2::FacadeFactory::instance().registerFacade<Akonadi2::Domain::Event, DummyResourceFacade>("dummyresource", []() {
35 return new DummyResourceFacade();
36 });
37 }
38
39 void cleanupTestCase()
40 {
41 Akonadi2::Storage storage(testDataPath, dbName);
42 storage.removeFromDisk();
43 }
44
45 void testScan()
46 {
47 const int count = 100;
48 populate(count);
49
50 Akonadi2::Query query;
51 query.ids << "key50";
52 query.resources << "dummyresource";
53
54 //FIXME avoid sync somehow. No synchronizer access here (perhaps configure the instance above accordingly?)
55 async::SyncListResult<Akonadi2::Domain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::Domain::Event>(query));
56 result.exec();
57 QCOMPARE(result.size(), 1);
58
59 Akonadi2::Storage storage(testDataPath, dbName);
60 storage.removeFromDisk();
61 }
62
63};
64
65QTEST_MAIN(DummyResourceFacadeTest)
66#include "dummyresourcefacadetest.moc"