summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-07 02:34:10 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-07 02:34:10 +0200
commita98311fbc807b83ecfc65a17f98464e5f1f9b3f8 (patch)
treea0c954404535fa832f7ddbd4f455fc67fe69bf4e /tests/storagetest.cpp
parent32c507fa0565547a187632db8a80c07babb95d9d (diff)
downloadsink-a98311fbc807b83ecfc65a17f98464e5f1f9b3f8.tar.gz
sink-a98311fbc807b83ecfc65a17f98464e5f1f9b3f8.zip
Fixed getUids by type filtering.
We used to simply return all uids. Requires "sinksh upgrade"
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index 9e9bad9..3368549 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -542,6 +542,35 @@ private slots:
542 } 542 }
543 543
544 } 544 }
545
546 void testRecordUid()
547 {
548 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
549 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
550 Sink::Storage::DataStore::recordUid(transaction, "uid1", "type");
551 Sink::Storage::DataStore::recordUid(transaction, "uid2", "type");
552 Sink::Storage::DataStore::recordUid(transaction, "uid3", "type2");
553
554 {
555 QVector<QByteArray> uids;
556 Sink::Storage::DataStore::getUids("type", transaction, [&](const QByteArray &r) {
557 uids << r;
558 });
559 QVector<QByteArray> expected{{"uid1"}, {"uid2"}};
560 QCOMPARE(uids, expected);
561 }
562
563 Sink::Storage::DataStore::removeUid(transaction, "uid2", "type");
564
565 {
566 QVector<QByteArray> uids;
567 Sink::Storage::DataStore::getUids("type", transaction, [&](const QByteArray &r) {
568 uids << r;
569 });
570 QVector<QByteArray> expected{{"uid1"}};
571 QCOMPARE(uids, expected);
572 }
573 }
545}; 574};
546 575
547QTEST_MAIN(StorageTest) 576QTEST_MAIN(StorageTest)