summaryrefslogtreecommitdiffstats
path: root/tests/indextest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-22 11:25:26 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-22 11:25:26 +0200
commit6746247a49f09287ae4924c5c3df791f9bf61cbc (patch)
treeb9df15f1e6413a8995704cf9f0c5f425c9bb9558 /tests/indextest.cpp
parentfc3a5df884b25d5e624027b1fb017f42986980b2 (diff)
downloadsink-6746247a49f09287ae4924c5c3df791f9bf61cbc.tar.gz
sink-6746247a49f09287ae4924c5c3df791f9bf61cbc.zip
Use named databases in storage.
This will allow us to create indexes in the same store.
Diffstat (limited to 'tests/indextest.cpp')
-rw-r--r--tests/indextest.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/tests/indextest.cpp b/tests/indextest.cpp
index 24f90c8..e3eabcc 100644
--- a/tests/indextest.cpp
+++ b/tests/indextest.cpp
@@ -13,38 +13,39 @@ class IndexTest : public QObject
13private Q_SLOTS: 13private Q_SLOTS:
14 void initTestCase() 14 void initTestCase()
15 { 15 {
16 Akonadi2::Storage store(Akonadi2::Store::storageLocation(), "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite); 16 Akonadi2::Storage store("./testindex", "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite);
17 store.removeFromDisk(); 17 store.removeFromDisk();
18 } 18 }
19 19
20 void cleanup() 20 void cleanup()
21 { 21 {
22 Akonadi2::Storage store(Akonadi2::Store::storageLocation(), "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite); 22 Akonadi2::Storage store("./testindex", "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite);
23 store.removeFromDisk(); 23 store.removeFromDisk();
24 } 24 }
25 25
26 void testIndex() 26 void testIndex()
27 { 27 {
28 Index index(Akonadi2::Store::storageLocation(), "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite); 28 Index index("./testindex", "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite);
29 index.add("key1", "value1"); 29 //The first key is specifically a substring of the second key
30 index.add("key1", "value2"); 30 index.add("key", "value1");
31 index.add("key2", "value3"); 31 index.add("keyFoo", "value2");
32 index.add("keyFoo", "value3");
32 33
33 { 34 {
34 QList<QByteArray> values; 35 QList<QByteArray> values;
35 index.lookup(QByteArray("key1"), [&values](const QByteArray &value) { 36 index.lookup(QByteArray("key"), [&values](const QByteArray &value) {
36 values << value; 37 values << value;
37 }, 38 },
38 [](const Index::Error &error){ qWarning() << "Error: "; }); 39 [](const Index::Error &error){ qWarning() << "Error: "; });
39 QCOMPARE(values.size(), 2); 40 QCOMPARE(values.size(), 1);
40 } 41 }
41 { 42 {
42 QList<QByteArray> values; 43 QList<QByteArray> values;
43 index.lookup(QByteArray("key2"), [&values](const QByteArray &value) { 44 index.lookup(QByteArray("keyFoo"), [&values](const QByteArray &value) {
44 values << value; 45 values << value;
45 }, 46 },
46 [](const Index::Error &error){ qWarning() << "Error: "; }); 47 [](const Index::Error &error){ qWarning() << "Error: "; });
47 QCOMPARE(values.size(), 1); 48 QCOMPARE(values.size(), 2);
48 } 49 }
49 { 50 {
50 QList<QByteArray> values; 51 QList<QByteArray> values;