summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
authorRémi Nicole <nicole@kolabsystems.com>2018-07-27 13:32:39 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-27 13:47:43 +0200
commitd1838e575baeb6cd08011645609516acbdabd6c8 (patch)
tree035b99a4d324231c8c44e0e97905383266bacba6 /tests/storagetest.cpp
parent1855b8356e4c427efdba4c932fa9f984e6ae5a43 (diff)
downloadsink-d1838e575baeb6cd08011645609516acbdabd6c8.tar.gz
sink-d1838e575baeb6cd08011645609516acbdabd6c8.zip
New Key API in storage layer
Summary: - Use object oriented paradigm for Keys / Identifiers /Revisions - "Compress" keys by using byte representation of Uuids - Still some cleaning left to do - Also run some benchmarks - I'm questioning whether files other than entitystore (tests excluded) are allowed to access this API Reviewers: cmollekopf Reviewed By: cmollekopf Tags: #sink Differential Revision: https://phabricator.kde.org/D13735
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index 96368a7..e165616 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -7,6 +7,7 @@
7#include <QtConcurrent/QtConcurrentRun> 7#include <QtConcurrent/QtConcurrentRun>
8 8
9#include "common/storage.h" 9#include "common/storage.h"
10#include "storage/key.h"
10 11
11/** 12/**
12 * Test of the storage implementation to ensure it can do the low level operations as expected. 13 * Test of the storage implementation to ensure it can do the low level operations as expected.
@@ -499,8 +500,11 @@ private slots:
499 auto db = transaction.openDatabase("test", nullptr, false); 500 auto db = transaction.openDatabase("test", nullptr, false);
500 const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}"; 501 const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}";
501 //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6) 502 //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6)
502 db.write(Sink::Storage::DataStore::assembleKey(uid, 6), "value1"); 503 const auto id = Sink::Storage::Identifier::fromDisplayByteArray(uid);
503 db.write(Sink::Storage::DataStore::assembleKey(uid, 10), "value2"); 504 auto key = Sink::Storage::Key(id, 6);
505 db.write(key.toInternalByteArray(), "value1");
506 key.setRevision(10);
507 db.write(key.toInternalByteArray(), "value2");
504 db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; }); 508 db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; });
505 QCOMPARE(result, QByteArray("value2")); 509 QCOMPARE(result, QByteArray("value2"));
506 } 510 }
@@ -732,7 +736,7 @@ private slots:
732 Sink::Storage::DataStore::clearEnv(); 736 Sink::Storage::DataStore::clearEnv();
733 737
734 //Try to read-only dynamic opening of the db. 738 //Try to read-only dynamic opening of the db.
735 //This is the case if we don't have all databases available upon initializatoin and we don't (e.g. because the db hasn't been created yet) 739 //This is the case if we don't have all databases available upon initializatoin and we don't (e.g. because the db hasn't been created yet)
736 { 740 {
737 // Trick the db into not loading all dbs by passing in a bogus layout. 741 // Trick the db into not loading all dbs by passing in a bogus layout.
738 Sink::Storage::DataStore store(testDataPath, {dbName, {{"bogus", 0}}}, Sink::Storage::DataStore::ReadOnly); 742 Sink::Storage::DataStore store(testDataPath, {dbName, {{"bogus", 0}}}, Sink::Storage::DataStore::ReadOnly);
@@ -750,7 +754,7 @@ private slots:
750 754
751 Sink::Storage::DataStore::clearEnv(); 755 Sink::Storage::DataStore::clearEnv();
752 //Try to read-write dynamic opening of the db. 756 //Try to read-write dynamic opening of the db.
753 //This is the case if we don't have all databases available upon initializatoin and we don't (e.g. because the db hasn't been created yet) 757 //This is the case if we don't have all databases available upon initializatoin and we don't (e.g. because the db hasn't been created yet)
754 { 758 {
755 // Trick the db into not loading all dbs by passing in a bogus layout. 759 // Trick the db into not loading all dbs by passing in a bogus layout.
756 Sink::Storage::DataStore store(testDataPath, {dbName, {{"bogus", 0}}}, Sink::Storage::DataStore::ReadWrite); 760 Sink::Storage::DataStore store(testDataPath, {dbName, {{"bogus", 0}}}, Sink::Storage::DataStore::ReadWrite);