From c90ba4a98292a39eb0b3df12fd7e2dec0300e58d Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 26 Jun 2018 14:10:30 +0200 Subject: Move Key API into own files + some fixes --- tests/pipelinetest.cpp | 9 ++++++--- tests/querytest.cpp | 38 -------------------------------------- tests/storagetest.cpp | 1 + 3 files changed, 7 insertions(+), 41 deletions(-) (limited to 'tests') diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index 7431deb..5165d35 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp @@ -20,6 +20,7 @@ #include "domainadaptor.h" #include "definitions.h" #include "adaptorfactoryregistry.h" +#include "storage/key.h" static void removeFromDisk(const QString &name) { @@ -430,8 +431,8 @@ private slots: // Get uid of written entity auto keys = getKeys(instanceIdentifier(), "event.main"); QCOMPARE(keys.size(), 1); - const auto key = keys.first(); - const auto uid = Sink::Storage::DataStore::uidFromKey(key); + auto key = Sink::Storage::Key::fromInternalByteArray(keys.first()); + const auto uid = key.identifier().toDisplayByteArray(); //Simulate local modification { @@ -453,8 +454,10 @@ private slots: pipeline.commit(); } + key.setRevision(3); + // Ensure we've got the new revision with the modification - auto buffer = getEntity(instanceIdentifier(), "event.main", Sink::Storage::DataStore::assembleKey(uid, 3)); + auto buffer = getEntity(instanceIdentifier(), "event.main", key.toInternalByteArray()); QVERIFY(!buffer.isEmpty()); Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 41ce40c..7685086 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -1823,44 +1823,6 @@ private slots: } - void testOverlapLive() - { - eventsWithDates(); - - { - Sink::Query query; - query.resourceFilter("sink.dummy.instance1"); - query.setFlags(Query::LiveQuery); - query.filter(QueryBase::Comparator( - QVariantList{ QDateTime::fromString("2018-05-22T12:00:00Z", Qt::ISODate), - QDateTime::fromString("2018-05-30T13:00:00Z", Qt::ISODate) }, - QueryBase::Comparator::Overlap)); - auto model = Sink::Store::loadModel(query); - QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); - QCOMPARE(model->rowCount(), 5); - - Event event = Event::createEntity("sink.dummy.instance1"); - event.setExtractedStartTime(QDateTime::fromString("2018-05-23T12:00:00Z", Qt::ISODate)); - event.setExtractedEndTime(QDateTime::fromString("2018-05-23T13:00:00Z", Qt::ISODate)); - VERIFYEXEC(Sink::Store::create(event)); - - Event event2 = Event::createEntity("sink.dummy.instance1"); - event2.setExtractedStartTime(QDateTime::fromString("2018-05-33T12:00:00Z", Qt::ISODate)); - event2.setExtractedEndTime(QDateTime::fromString("2018-05-33T13:00:00Z", Qt::ISODate)); - VERIFYEXEC(Sink::Store::create(event2)); - - QTest::qWait(500); - QCOMPARE(model->rowCount(), 6); - - VERIFYEXEC(Sink::Store::remove(event)); - VERIFYEXEC(Sink::Store::remove(event2)); - - QTest::qWait(500); - QCOMPARE(model->rowCount(), 5); - } - - } - }; QTEST_MAIN(QueryTest) diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp index 40492f0..d3f180a 100644 --- a/tests/storagetest.cpp +++ b/tests/storagetest.cpp @@ -7,6 +7,7 @@ #include #include "common/storage.h" +#include "storage/key.h" /** * Test of the storage implementation to ensure it can do the low level operations as expected. -- cgit v1.2.3