summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2018-06-26 11:44:11 +0200
committerMinijackson <minijackson@riseup.net>2018-07-04 15:37:14 +0200
commit922e0979e2c27ff8dbc765ae151d17c7815b98a0 (patch)
treecb031c5d3ccc31ea576f66b4f718c17f5bb0775c /tests/storagetest.cpp
parent06f30d0f0d0051df97d4c34cd1a80b14857c9e9c (diff)
downloadsink-922e0979e2c27ff8dbc765ae151d17c7815b98a0.tar.gz
sink-922e0979e2c27ff8dbc765ae151d17c7815b98a0.zip
[Storage] Implement Key API
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index bca91b1..40492f0 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -456,8 +456,10 @@ private slots:
456 auto db = transaction.openDatabase("test", nullptr, false); 456 auto db = transaction.openDatabase("test", nullptr, false);
457 const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}"; 457 const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}";
458 //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6) 458 //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6)
459 db.write(Sink::Storage::DataStore::assembleKey(uid, 6), "value1"); 459 const auto key1 = Sink::Storage::Key(Sink::Storage::Identifier::fromDisplayByteArray(uid), 6);
460 db.write(Sink::Storage::DataStore::assembleKey(uid, 10), "value2"); 460 db.write(key1.toInternalByteArray(), "value1");
461 const auto key2 = Sink::Storage::Key(Sink::Storage::Identifier::fromDisplayByteArray(uid), 10);
462 db.write(key2.toInternalByteArray(), "value2");
461 db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; }); 463 db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; });
462 QCOMPARE(result, QByteArray("value2")); 464 QCOMPARE(result, QByteArray("value2"));
463 } 465 }
@@ -689,7 +691,7 @@ private slots:
689 Sink::Storage::DataStore::clearEnv(); 691 Sink::Storage::DataStore::clearEnv();
690 692
691 //Try to read-only dynamic opening of the db. 693 //Try to read-only dynamic opening of the db.
692 //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) 694 //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)
693 { 695 {
694 // Trick the db into not loading all dbs by passing in a bogus layout. 696 // Trick the db into not loading all dbs by passing in a bogus layout.
695 Sink::Storage::DataStore store(testDataPath, {dbName, {{"bogus", 0}}}, Sink::Storage::DataStore::ReadOnly); 697 Sink::Storage::DataStore store(testDataPath, {dbName, {{"bogus", 0}}}, Sink::Storage::DataStore::ReadOnly);
@@ -707,7 +709,7 @@ private slots:
707 709
708 Sink::Storage::DataStore::clearEnv(); 710 Sink::Storage::DataStore::clearEnv();
709 //Try to read-write dynamic opening of the db. 711 //Try to read-write dynamic opening of the db.
710 //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) 712 //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)
711 { 713 {
712 // Trick the db into not loading all dbs by passing in a bogus layout. 714 // Trick the db into not loading all dbs by passing in a bogus layout.
713 Sink::Storage::DataStore store(testDataPath, {dbName, {{"bogus", 0}}}, Sink::Storage::DataStore::ReadWrite); 715 Sink::Storage::DataStore store(testDataPath, {dbName, {{"bogus", 0}}}, Sink::Storage::DataStore::ReadWrite);