summaryrefslogtreecommitdiffstats
path: root/tests/storagetest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-16 14:55:20 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-21 09:02:21 +0200
commit237b9ae4113e7a9f489632296941becb71afdb45 (patch)
tree01cde58f495944f01cad9d282391d4efd2897141 /tests/storagetest.cpp
parent95d11bf0be98a4e3c08502fe23417b800233ce14 (diff)
downloadsink-237b9ae4113e7a9f489632296941becb71afdb45.tar.gz
sink-237b9ae4113e7a9f489632296941becb71afdb45.zip
Refactor how the storage is used.
This is the initial refactoring to improve how we deal with the storage. It does a couple of things: * Rename Sink::Storage to Sink::Storage::DataStore to free up the Sink::Storage namespace * Introduce a Sink::ResourceContext to have a single object that can be passed around containing everything that is necessary to operate on a resource. This is a lot better than the multiple separate parameters that we used to pass around all over the place, while still allowing for dependency injection for tests. * Tie storage access together using the new EntityStore that directly works with ApplicationDomainTypes. This gives us a central place where main storage, indexes and buffer adaptors are tied together, which will also give us a place to implement external indexes, such as a fulltextindex using xapian. * Use ApplicationDomainTypes as the default way to pass around entities. Instead of using various ways to pass around entities (buffers, buffer adaptors, ApplicationDomainTypes), only use a single way. The old approach was confusing, and was only done as: * optimization; really shouldn't be necessary and otherwise I'm sure we can find better ways to optimize ApplicationDomainType itself. * a way to account for entities that have multiple buffers, a concept that I no longer deem relevant. While this commit does the bulk of the work to get there, the following commits will refactor more stuff to get things back to normal.
Diffstat (limited to 'tests/storagetest.cpp')
-rw-r--r--tests/storagetest.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index aa12ec1..5a517c7 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -21,14 +21,14 @@ private:
21 21
22 void populate(int count) 22 void populate(int count)
23 { 23 {
24 Sink::Storage storage(testDataPath, dbName, Sink::Storage::ReadWrite); 24 Sink::Storage::DataStore storage(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
25 auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); 25 auto transaction = storage.createTransaction(Sink::Storage::DataStore::ReadWrite);
26 for (int i = 0; i < count; i++) { 26 for (int i = 0; i < count; i++) {
27 // This should perhaps become an implementation detail of the db? 27 // This should perhaps become an implementation detail of the db?
28 if (i % 10000 == 0) { 28 if (i % 10000 == 0) {
29 if (i > 0) { 29 if (i > 0) {
30 transaction.commit(); 30 transaction.commit();
31 transaction = storage.createTransaction(Sink::Storage::ReadWrite); 31 transaction = storage.createTransaction(Sink::Storage::DataStore::ReadWrite);
32 } 32 }
33 } 33 }
34 transaction.openDatabase().write(keyPrefix + QByteArray::number(i), keyPrefix + QByteArray::number(i)); 34 transaction.openDatabase().write(keyPrefix + QByteArray::number(i), keyPrefix + QByteArray::number(i));
@@ -36,12 +36,12 @@ private:
36 transaction.commit(); 36 transaction.commit();
37 } 37 }
38 38
39 bool verify(Sink::Storage &storage, int i) 39 bool verify(Sink::Storage::DataStore &storage, int i)
40 { 40 {
41 bool success = true; 41 bool success = true;
42 bool keyMatch = true; 42 bool keyMatch = true;
43 const auto reference = keyPrefix + QByteArray::number(i); 43 const auto reference = keyPrefix + QByteArray::number(i);
44 storage.createTransaction(Sink::Storage::ReadOnly) 44 storage.createTransaction(Sink::Storage::DataStore::ReadOnly)
45 .openDatabase() 45 .openDatabase()
46 .scan(keyPrefix + QByteArray::number(i), 46 .scan(keyPrefix + QByteArray::number(i),
47 [&keyMatch, &reference](const QByteArray &key, const QByteArray &value) -> bool { 47 [&keyMatch, &reference](const QByteArray &key, const QByteArray &value) -> bool {
@@ -51,7 +51,7 @@ private:
51 } 51 }
52 return keyMatch; 52 return keyMatch;
53 }, 53 },
54 [&success](const Sink::Storage::Error &error) { 54 [&success](const Sink::Storage::DataStore::Error &error) {
55 qDebug() << error.message; 55 qDebug() << error.message;
56 success = false; 56 success = false;
57 }); 57 });
@@ -63,20 +63,20 @@ private slots:
63 { 63 {
64 testDataPath = "./testdb"; 64 testDataPath = "./testdb";
65 dbName = "test"; 65 dbName = "test";
66 Sink::Storage storage(testDataPath, dbName); 66 Sink::Storage::DataStore storage(testDataPath, dbName);
67 storage.removeFromDisk(); 67 storage.removeFromDisk();
68 } 68 }
69 69
70 void cleanup() 70 void cleanup()
71 { 71 {
72 Sink::Storage storage(testDataPath, dbName); 72 Sink::Storage::DataStore storage(testDataPath, dbName);
73 storage.removeFromDisk(); 73 storage.removeFromDisk();
74 } 74 }
75 75
76 void testCleanup() 76 void testCleanup()
77 { 77 {
78 populate(1); 78 populate(1);
79 Sink::Storage storage(testDataPath, dbName); 79 Sink::Storage::DataStore storage(testDataPath, dbName);
80 storage.removeFromDisk(); 80 storage.removeFromDisk();
81 QFileInfo info(testDataPath + "/" + dbName); 81 QFileInfo info(testDataPath + "/" + dbName);
82 QVERIFY(!info.exists()); 82 QVERIFY(!info.exists());
@@ -90,7 +90,7 @@ private slots:
90 90
91 // ensure we can read everything back correctly 91 // ensure we can read everything back correctly
92 { 92 {
93 Sink::Storage storage(testDataPath, dbName); 93 Sink::Storage::DataStore storage(testDataPath, dbName);
94 for (int i = 0; i < count; i++) { 94 for (int i = 0; i < count; i++) {
95 QVERIFY(verify(storage, i)); 95 QVERIFY(verify(storage, i));
96 } 96 }
@@ -105,8 +105,8 @@ private slots:
105 // ensure we can scan for values 105 // ensure we can scan for values
106 { 106 {
107 int hit = 0; 107 int hit = 0;
108 Sink::Storage store(testDataPath, dbName); 108 Sink::Storage::DataStore store(testDataPath, dbName);
109 store.createTransaction(Sink::Storage::ReadOnly) 109 store.createTransaction(Sink::Storage::DataStore::ReadOnly)
110 .openDatabase() 110 .openDatabase()
111 .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { 111 .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool {
112 if (key == "key50") { 112 if (key == "key50") {
@@ -121,8 +121,8 @@ private slots:
121 { 121 {
122 int hit = 0; 122 int hit = 0;
123 bool foundInvalidValue = false; 123 bool foundInvalidValue = false;
124 Sink::Storage store(testDataPath, dbName); 124 Sink::Storage::DataStore store(testDataPath, dbName);
125 store.createTransaction(Sink::Storage::ReadOnly) 125 store.createTransaction(Sink::Storage::DataStore::ReadOnly)
126 .openDatabase() 126 .openDatabase()
127 .scan("key50", [&](const QByteArray &key, const QByteArray &value) -> bool { 127 .scan("key50", [&](const QByteArray &key, const QByteArray &value) -> bool {
128 if (key != "key50") { 128 if (key != "key50") {
@@ -139,10 +139,10 @@ private slots:
139 void testNestedOperations() 139 void testNestedOperations()
140 { 140 {
141 populate(3); 141 populate(3);
142 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 142 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
143 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 143 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
144 transaction.openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { 144 transaction.openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool {
145 transaction.openDatabase().remove(key, [](const Sink::Storage::Error &) { QVERIFY(false); }); 145 transaction.openDatabase().remove(key, [](const Sink::Storage::DataStore::Error &) { QVERIFY(false); });
146 return false; 146 return false;
147 }); 147 });
148 } 148 }
@@ -150,11 +150,11 @@ private slots:
150 void testNestedTransactions() 150 void testNestedTransactions()
151 { 151 {
152 populate(3); 152 populate(3);
153 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 153 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
154 store.createTransaction(Sink::Storage::ReadOnly) 154 store.createTransaction(Sink::Storage::DataStore::ReadOnly)
155 .openDatabase() 155 .openDatabase()
156 .scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { 156 .scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool {
157 store.createTransaction(Sink::Storage::ReadWrite).openDatabase().remove(key, [](const Sink::Storage::Error &) { QVERIFY(false); }); 157 store.createTransaction(Sink::Storage::DataStore::ReadWrite).openDatabase().remove(key, [](const Sink::Storage::DataStore::Error &) { QVERIFY(false); });
158 return false; 158 return false;
159 }); 159 });
160 } 160 }
@@ -163,9 +163,9 @@ private slots:
163 { 163 {
164 bool gotResult = false; 164 bool gotResult = false;
165 bool gotError = false; 165 bool gotError = false;
166 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 166 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
167 auto transaction = store.createTransaction(Sink::Storage::ReadOnly); 167 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
168 auto db = transaction.openDatabase("default", [&](const Sink::Storage::Error &error) { 168 auto db = transaction.openDatabase("default", [&](const Sink::Storage::DataStore::Error &error) {
169 qDebug() << error.message; 169 qDebug() << error.message;
170 gotError = true; 170 gotError = true;
171 }); 171 });
@@ -174,7 +174,7 @@ private slots:
174 gotResult = true; 174 gotResult = true;
175 return false; 175 return false;
176 }, 176 },
177 [&](const Sink::Storage::Error &error) { 177 [&](const Sink::Storage::DataStore::Error &error) {
178 qDebug() << error.message; 178 qDebug() << error.message;
179 gotError = true; 179 gotError = true;
180 }); 180 });
@@ -199,8 +199,8 @@ private slots:
199 const int concurrencyLevel = 20; 199 const int concurrencyLevel = 20;
200 for (int num = 0; num < concurrencyLevel; num++) { 200 for (int num = 0; num < concurrencyLevel; num++) {
201 futures << QtConcurrent::run([this, count, &error]() { 201 futures << QtConcurrent::run([this, count, &error]() {
202 Sink::Storage storage(testDataPath, dbName, Sink::Storage::ReadOnly); 202 Sink::Storage::DataStore storage(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly);
203 Sink::Storage storage2(testDataPath, dbName + "2", Sink::Storage::ReadOnly); 203 Sink::Storage::DataStore storage2(testDataPath, dbName + "2", Sink::Storage::DataStore::ReadOnly);
204 for (int i = 0; i < count; i++) { 204 for (int i = 0; i < count; i++) {
205 if (!verify(storage, i)) { 205 if (!verify(storage, i)) {
206 error = true; 206 error = true;
@@ -216,9 +216,9 @@ private slots:
216 } 216 }
217 217
218 { 218 {
219 Sink::Storage storage(testDataPath, dbName); 219 Sink::Storage::DataStore storage(testDataPath, dbName);
220 storage.removeFromDisk(); 220 storage.removeFromDisk();
221 Sink::Storage storage2(testDataPath, dbName + "2"); 221 Sink::Storage::DataStore storage2(testDataPath, dbName + "2");
222 storage2.removeFromDisk(); 222 storage2.removeFromDisk();
223 } 223 }
224 } 224 }
@@ -227,8 +227,8 @@ private slots:
227 { 227 {
228 bool gotResult = false; 228 bool gotResult = false;
229 bool gotError = false; 229 bool gotError = false;
230 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 230 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
231 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 231 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
232 auto db = transaction.openDatabase("default", nullptr, false); 232 auto db = transaction.openDatabase("default", nullptr, false);
233 db.write("key", "value"); 233 db.write("key", "value");
234 db.write("key", "value"); 234 db.write("key", "value");
@@ -238,7 +238,7 @@ private slots:
238 gotResult = true; 238 gotResult = true;
239 return true; 239 return true;
240 }, 240 },
241 [&](const Sink::Storage::Error &error) { 241 [&](const Sink::Storage::DataStore::Error &error) {
242 qDebug() << error.message; 242 qDebug() << error.message;
243 gotError = true; 243 gotError = true;
244 }); 244 });
@@ -252,8 +252,8 @@ private slots:
252 { 252 {
253 bool gotResult = false; 253 bool gotResult = false;
254 bool gotError = false; 254 bool gotError = false;
255 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 255 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
256 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 256 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
257 auto db = transaction.openDatabase("default", nullptr, true); 257 auto db = transaction.openDatabase("default", nullptr, true);
258 db.write("key", "value1"); 258 db.write("key", "value1");
259 db.write("key", "value2"); 259 db.write("key", "value2");
@@ -262,7 +262,7 @@ private slots:
262 gotResult = true; 262 gotResult = true;
263 return true; 263 return true;
264 }, 264 },
265 [&](const Sink::Storage::Error &error) { 265 [&](const Sink::Storage::DataStore::Error &error) {
266 qDebug() << error.message; 266 qDebug() << error.message;
267 gotError = true; 267 gotError = true;
268 }); 268 });
@@ -275,15 +275,15 @@ private slots:
275 { 275 {
276 bool gotResult = false; 276 bool gotResult = false;
277 bool gotError = false; 277 bool gotError = false;
278 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadOnly); 278 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly);
279 int numValues = store.createTransaction(Sink::Storage::ReadOnly) 279 int numValues = store.createTransaction(Sink::Storage::DataStore::ReadOnly)
280 .openDatabase("test") 280 .openDatabase("test")
281 .scan("", 281 .scan("",
282 [&](const QByteArray &key, const QByteArray &value) -> bool { 282 [&](const QByteArray &key, const QByteArray &value) -> bool {
283 gotResult = true; 283 gotResult = true;
284 return false; 284 return false;
285 }, 285 },
286 [&](const Sink::Storage::Error &error) { 286 [&](const Sink::Storage::DataStore::Error &error) {
287 qDebug() << error.message; 287 qDebug() << error.message;
288 gotError = true; 288 gotError = true;
289 }); 289 });
@@ -295,10 +295,10 @@ private slots:
295 void testWriteToNamedDb() 295 void testWriteToNamedDb()
296 { 296 {
297 bool gotError = false; 297 bool gotError = false;
298 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 298 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
299 store.createTransaction(Sink::Storage::ReadWrite) 299 store.createTransaction(Sink::Storage::DataStore::ReadWrite)
300 .openDatabase("test") 300 .openDatabase("test")
301 .write("key1", "value1", [&](const Sink::Storage::Error &error) { 301 .write("key1", "value1", [&](const Sink::Storage::DataStore::Error &error) {
302 qDebug() << error.message; 302 qDebug() << error.message;
303 gotError = true; 303 gotError = true;
304 }); 304 });
@@ -308,10 +308,10 @@ private slots:
308 void testWriteDuplicatesToNamedDb() 308 void testWriteDuplicatesToNamedDb()
309 { 309 {
310 bool gotError = false; 310 bool gotError = false;
311 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 311 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
312 store.createTransaction(Sink::Storage::ReadWrite) 312 store.createTransaction(Sink::Storage::DataStore::ReadWrite)
313 .openDatabase("test", nullptr, true) 313 .openDatabase("test", nullptr, true)
314 .write("key1", "value1", [&](const Sink::Storage::Error &error) { 314 .write("key1", "value1", [&](const Sink::Storage::DataStore::Error &error) {
315 qDebug() << error.message; 315 qDebug() << error.message;
316 gotError = true; 316 gotError = true;
317 }); 317 });
@@ -321,8 +321,8 @@ private slots:
321 // By default we want only exact matches 321 // By default we want only exact matches
322 void testSubstringKeys() 322 void testSubstringKeys()
323 { 323 {
324 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 324 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
325 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 325 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
326 auto db = transaction.openDatabase("test", nullptr, true); 326 auto db = transaction.openDatabase("test", nullptr, true);
327 db.write("sub", "value1"); 327 db.write("sub", "value1");
328 db.write("subsub", "value2"); 328 db.write("subsub", "value2");
@@ -333,8 +333,8 @@ private slots:
333 333
334 void testFindSubstringKeys() 334 void testFindSubstringKeys()
335 { 335 {
336 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 336 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
337 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 337 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
338 auto db = transaction.openDatabase("test", nullptr, false); 338 auto db = transaction.openDatabase("test", nullptr, false);
339 db.write("sub", "value1"); 339 db.write("sub", "value1");
340 db.write("subsub", "value2"); 340 db.write("subsub", "value2");
@@ -346,8 +346,8 @@ private slots:
346 346
347 void testFindSubstringKeysWithDuplicatesEnabled() 347 void testFindSubstringKeysWithDuplicatesEnabled()
348 { 348 {
349 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 349 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
350 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 350 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
351 auto db = transaction.openDatabase("test", nullptr, true); 351 auto db = transaction.openDatabase("test", nullptr, true);
352 db.write("sub", "value1"); 352 db.write("sub", "value1");
353 db.write("subsub", "value2"); 353 db.write("subsub", "value2");
@@ -359,8 +359,8 @@ private slots:
359 359
360 void testKeySorting() 360 void testKeySorting()
361 { 361 {
362 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 362 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
363 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 363 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
364 auto db = transaction.openDatabase("test", nullptr, false); 364 auto db = transaction.openDatabase("test", nullptr, false);
365 db.write("sub_2", "value2"); 365 db.write("sub_2", "value2");
366 db.write("sub_1", "value1"); 366 db.write("sub_1", "value1");
@@ -380,8 +380,8 @@ private slots:
380 // Ensure we don't retrieve a key that is greater than the current key. We only want equal keys. 380 // Ensure we don't retrieve a key that is greater than the current key. We only want equal keys.
381 void testKeyRange() 381 void testKeyRange()
382 { 382 {
383 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 383 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
384 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 384 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
385 auto db = transaction.openDatabase("test", nullptr, true); 385 auto db = transaction.openDatabase("test", nullptr, true);
386 db.write("sub1", "value1"); 386 db.write("sub1", "value1");
387 int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { return true; }); 387 int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { return true; });
@@ -391,8 +391,8 @@ private slots:
391 391
392 void testFindLatest() 392 void testFindLatest()
393 { 393 {
394 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 394 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
395 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 395 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
396 auto db = transaction.openDatabase("test", nullptr, false); 396 auto db = transaction.openDatabase("test", nullptr, false);
397 db.write("sub1", "value1"); 397 db.write("sub1", "value1");
398 db.write("sub2", "value2"); 398 db.write("sub2", "value2");
@@ -406,8 +406,8 @@ private slots:
406 406
407 void testFindLatestInSingle() 407 void testFindLatestInSingle()
408 { 408 {
409 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 409 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
410 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 410 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
411 auto db = transaction.openDatabase("test", nullptr, false); 411 auto db = transaction.openDatabase("test", nullptr, false);
412 db.write("sub2", "value2"); 412 db.write("sub2", "value2");
413 QByteArray result; 413 QByteArray result;
@@ -418,8 +418,8 @@ private slots:
418 418
419 void testFindLast() 419 void testFindLast()
420 { 420 {
421 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 421 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
422 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 422 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
423 auto db = transaction.openDatabase("test", nullptr, false); 423 auto db = transaction.openDatabase("test", nullptr, false);
424 db.write("sub2", "value2"); 424 db.write("sub2", "value2");
425 db.write("wub3", "value3"); 425 db.write("wub3", "value3");
@@ -431,23 +431,23 @@ private slots:
431 431
432 void testRecordRevision() 432 void testRecordRevision()
433 { 433 {
434 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 434 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
435 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 435 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
436 Sink::Storage::recordRevision(transaction, 1, "uid", "type"); 436 Sink::Storage::DataStore::recordRevision(transaction, 1, "uid", "type");
437 QCOMPARE(Sink::Storage::getTypeFromRevision(transaction, 1), QByteArray("type")); 437 QCOMPARE(Sink::Storage::DataStore::getTypeFromRevision(transaction, 1), QByteArray("type"));
438 QCOMPARE(Sink::Storage::getUidFromRevision(transaction, 1), QByteArray("uid")); 438 QCOMPARE(Sink::Storage::DataStore::getUidFromRevision(transaction, 1), QByteArray("uid"));
439 } 439 }
440 440
441 void testRecordRevisionSorting() 441 void testRecordRevisionSorting()
442 { 442 {
443 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 443 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
444 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 444 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
445 QByteArray result; 445 QByteArray result;
446 auto db = transaction.openDatabase("test", nullptr, false); 446 auto db = transaction.openDatabase("test", nullptr, false);
447 const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}"; 447 const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}";
448 //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6) 448 //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6)
449 db.write(Sink::Storage::assembleKey(uid, 6), "value1"); 449 db.write(Sink::Storage::DataStore::assembleKey(uid, 6), "value1");
450 db.write(Sink::Storage::assembleKey(uid, 10), "value2"); 450 db.write(Sink::Storage::DataStore::assembleKey(uid, 10), "value2");
451 db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; }); 451 db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; });
452 QCOMPARE(result, QByteArray("value2")); 452 QCOMPARE(result, QByteArray("value2"));
453 } 453 }