summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pipelinetest.cpp29
-rw-r--r--tests/storagetest.cpp10
2 files changed, 25 insertions, 14 deletions
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp
index 45e2fbb..7431deb 100644
--- a/tests/pipelinetest.cpp
+++ b/tests/pipelinetest.cpp
@@ -250,8 +250,9 @@ private slots:
250 // Get uid of written entity 250 // Get uid of written entity
251 auto keys = getKeys(instanceIdentifier(), "event.main"); 251 auto keys = getKeys(instanceIdentifier(), "event.main");
252 QCOMPARE(keys.size(), 1); 252 QCOMPARE(keys.size(), 1);
253 const auto key = keys.first(); 253 auto key = Sink::Storage::Key::fromInternalByteArray(keys.first());
254 const auto uid = Sink::Storage::DataStore::uidFromKey(key); 254 //const auto uid = Sink::Storage::DataStore::uidFromKey(key);
255 const auto uid = key.identifier().toDisplayByteArray();
255 256
256 // Execute the modification 257 // Execute the modification
257 entityFbb.Clear(); 258 entityFbb.Clear();
@@ -260,8 +261,10 @@ private slots:
260 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); 261 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size());
261 pipeline.commit(); 262 pipeline.commit();
262 263
264 key.setRevision(2);
265
263 // Ensure we've got the new revision with the modification 266 // Ensure we've got the new revision with the modification
264 auto buffer = getEntity(instanceIdentifier(), "event.main", Sink::Storage::DataStore::assembleKey(uid, 2)); 267 auto buffer = getEntity(instanceIdentifier(), "event.main", key.toInternalByteArray());
265 QVERIFY(!buffer.isEmpty()); 268 QVERIFY(!buffer.isEmpty());
266 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); 269 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size());
267 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); 270 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity());
@@ -296,7 +299,8 @@ private slots:
296 // Get uid of written entity 299 // Get uid of written entity
297 auto keys = getKeys(instanceIdentifier(), "event.main"); 300 auto keys = getKeys(instanceIdentifier(), "event.main");
298 QCOMPARE(keys.size(), 1); 301 QCOMPARE(keys.size(), 1);
299 const auto uid = Sink::Storage::DataStore::uidFromKey(keys.first()); 302 auto key = Sink::Storage::Key::fromInternalByteArray(keys.first());
303 const auto uid = key.identifier().toDisplayByteArray();
300 304
301 305
302 // Create another operation inbetween 306 // Create another operation inbetween
@@ -315,8 +319,10 @@ private slots:
315 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); 319 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size());
316 pipeline.commit(); 320 pipeline.commit();
317 321
322 key.setRevision(3);
323
318 // Ensure we've got the new revision with the modification 324 // Ensure we've got the new revision with the modification
319 auto buffer = getEntity(instanceIdentifier(), "event.main", Sink::Storage::DataStore::assembleKey(uid, 3)); 325 auto buffer = getEntity(instanceIdentifier(), "event.main", key.toInternalByteArray());
320 QVERIFY(!buffer.isEmpty()); 326 QVERIFY(!buffer.isEmpty());
321 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); 327 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size());
322 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); 328 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity());
@@ -337,7 +343,7 @@ private slots:
337 auto result = getKeys(instanceIdentifier(), "event.main"); 343 auto result = getKeys(instanceIdentifier(), "event.main");
338 QCOMPARE(result.size(), 1); 344 QCOMPARE(result.size(), 1);
339 345
340 const auto uid = Sink::Storage::DataStore::uidFromKey(result.first()); 346 const auto uid = Sink::Storage::Key::fromInternalByteArray(result.first()).identifier().toDisplayByteArray();
341 347
342 // Delete entity 348 // Delete entity
343 auto deleteCommand = deleteEntityCommand(uid, 1); 349 auto deleteCommand = deleteEntityCommand(uid, 1);
@@ -373,21 +379,23 @@ private slots:
373 QCOMPARE(testProcessor->newUids.size(), 1); 379 QCOMPARE(testProcessor->newUids.size(), 1);
374 QCOMPARE(testProcessor->newRevisions.size(), 1); 380 QCOMPARE(testProcessor->newRevisions.size(), 1);
375 // Key doesn't contain revision and is just the uid 381 // Key doesn't contain revision and is just the uid
376 QCOMPARE(testProcessor->newUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->newUids.at(0))); 382 const auto uid = Sink::Storage::Key::fromDisplayByteArray(testProcessor->newUids.at(0)).identifier().toDisplayByteArray();
383 QCOMPARE(testProcessor->newUids.at(0), uid);
377 } 384 }
378 pipeline.commit(); 385 pipeline.commit();
379 entityFbb.Clear(); 386 entityFbb.Clear();
380 pipeline.startTransaction(); 387 pipeline.startTransaction();
381 auto keys = getKeys(instanceIdentifier(), "event.main"); 388 auto keys = getKeys(instanceIdentifier(), "event.main");
382 QCOMPARE(keys.size(), 1); 389 QCOMPARE(keys.size(), 1);
383 const auto uid = Sink::Storage::DataStore::uidFromKey(keys.first()); 390 const auto uid = Sink::Storage::Key::fromDisplayByteArray(keys.first()).identifier().toDisplayByteArray();
384 { 391 {
385 auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1); 392 auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1);
386 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); 393 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size());
387 QCOMPARE(testProcessor->modifiedUids.size(), 1); 394 QCOMPARE(testProcessor->modifiedUids.size(), 1);
388 QCOMPARE(testProcessor->modifiedRevisions.size(), 1); 395 QCOMPARE(testProcessor->modifiedRevisions.size(), 1);
389 // Key doesn't contain revision and is just the uid 396 // Key doesn't contain revision and is just the uid
390 QCOMPARE(testProcessor->modifiedUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->modifiedUids.at(0))); 397 const auto uid2 = Sink::Storage::Key::fromDisplayByteArray(testProcessor->modifiedUids.at(0)).identifier().toDisplayByteArray();
398 QCOMPARE(testProcessor->modifiedUids.at(0), uid2);
391 } 399 }
392 pipeline.commit(); 400 pipeline.commit();
393 entityFbb.Clear(); 401 entityFbb.Clear();
@@ -399,7 +407,8 @@ private slots:
399 QCOMPARE(testProcessor->deletedUids.size(), 1); 407 QCOMPARE(testProcessor->deletedUids.size(), 1);
400 QCOMPARE(testProcessor->deletedSummaries.size(), 1); 408 QCOMPARE(testProcessor->deletedSummaries.size(), 1);
401 // Key doesn't contain revision and is just the uid 409 // Key doesn't contain revision and is just the uid
402 QCOMPARE(testProcessor->deletedUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->deletedUids.at(0))); 410 const auto uid2 = Sink::Storage::Key::fromDisplayByteArray(testProcessor->modifiedUids.at(0)).identifier().toDisplayByteArray();
411 QCOMPARE(testProcessor->deletedUids.at(0), uid2);
403 QCOMPARE(testProcessor->deletedSummaries.at(0), QByteArray("summary2")); 412 QCOMPARE(testProcessor->deletedSummaries.at(0), QByteArray("summary2"));
404 } 413 }
405 } 414 }
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);