diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-08-22 11:25:26 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-08-22 11:25:26 +0200 |
commit | 6746247a49f09287ae4924c5c3df791f9bf61cbc (patch) | |
tree | b9df15f1e6413a8995704cf9f0c5f425c9bb9558 /tests/indextest.cpp | |
parent | fc3a5df884b25d5e624027b1fb017f42986980b2 (diff) | |
download | sink-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.cpp | 21 |
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 | |||
13 | private Q_SLOTS: | 13 | private 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; |