summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pipelinetest.cpp9
-rw-r--r--tests/querytest.cpp38
-rw-r--r--tests/storagetest.cpp1
3 files changed, 7 insertions, 41 deletions
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 @@
20#include "domainadaptor.h" 20#include "domainadaptor.h"
21#include "definitions.h" 21#include "definitions.h"
22#include "adaptorfactoryregistry.h" 22#include "adaptorfactoryregistry.h"
23#include "storage/key.h"
23 24
24static void removeFromDisk(const QString &name) 25static void removeFromDisk(const QString &name)
25{ 26{
@@ -430,8 +431,8 @@ private slots:
430 // Get uid of written entity 431 // Get uid of written entity
431 auto keys = getKeys(instanceIdentifier(), "event.main"); 432 auto keys = getKeys(instanceIdentifier(), "event.main");
432 QCOMPARE(keys.size(), 1); 433 QCOMPARE(keys.size(), 1);
433 const auto key = keys.first(); 434 auto key = Sink::Storage::Key::fromInternalByteArray(keys.first());
434 const auto uid = Sink::Storage::DataStore::uidFromKey(key); 435 const auto uid = key.identifier().toDisplayByteArray();
435 436
436 //Simulate local modification 437 //Simulate local modification
437 { 438 {
@@ -453,8 +454,10 @@ private slots:
453 pipeline.commit(); 454 pipeline.commit();
454 } 455 }
455 456
457 key.setRevision(3);
458
456 // Ensure we've got the new revision with the modification 459 // Ensure we've got the new revision with the modification
457 auto buffer = getEntity(instanceIdentifier(), "event.main", Sink::Storage::DataStore::assembleKey(uid, 3)); 460 auto buffer = getEntity(instanceIdentifier(), "event.main", key.toInternalByteArray());
458 QVERIFY(!buffer.isEmpty()); 461 QVERIFY(!buffer.isEmpty());
459 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); 462 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size());
460 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); 463 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:
1823 1823
1824 } 1824 }
1825 1825
1826 void testOverlapLive()
1827 {
1828 eventsWithDates();
1829
1830 {
1831 Sink::Query query;
1832 query.resourceFilter("sink.dummy.instance1");
1833 query.setFlags(Query::LiveQuery);
1834 query.filter<Event::StartTime, Event::EndTime>(QueryBase::Comparator(
1835 QVariantList{ QDateTime::fromString("2018-05-22T12:00:00Z", Qt::ISODate),
1836 QDateTime::fromString("2018-05-30T13:00:00Z", Qt::ISODate) },
1837 QueryBase::Comparator::Overlap));
1838 auto model = Sink::Store::loadModel<Event>(query);
1839 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
1840 QCOMPARE(model->rowCount(), 5);
1841
1842 Event event = Event::createEntity<Event>("sink.dummy.instance1");
1843 event.setExtractedStartTime(QDateTime::fromString("2018-05-23T12:00:00Z", Qt::ISODate));
1844 event.setExtractedEndTime(QDateTime::fromString("2018-05-23T13:00:00Z", Qt::ISODate));
1845 VERIFYEXEC(Sink::Store::create<Event>(event));
1846
1847 Event event2 = Event::createEntity<Event>("sink.dummy.instance1");
1848 event2.setExtractedStartTime(QDateTime::fromString("2018-05-33T12:00:00Z", Qt::ISODate));
1849 event2.setExtractedEndTime(QDateTime::fromString("2018-05-33T13:00:00Z", Qt::ISODate));
1850 VERIFYEXEC(Sink::Store::create<Event>(event2));
1851
1852 QTest::qWait(500);
1853 QCOMPARE(model->rowCount(), 6);
1854
1855 VERIFYEXEC(Sink::Store::remove<Event>(event));
1856 VERIFYEXEC(Sink::Store::remove<Event>(event2));
1857
1858 QTest::qWait(500);
1859 QCOMPARE(model->rowCount(), 5);
1860 }
1861
1862 }
1863
1864}; 1826};
1865 1827
1866QTEST_MAIN(QueryTest) 1828QTEST_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 @@
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.