diff options
author | Minijackson <minijackson@riseup.net> | 2018-06-26 14:10:30 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-07-04 15:37:14 +0200 |
commit | c90ba4a98292a39eb0b3df12fd7e2dec0300e58d (patch) | |
tree | 0c0c252087e6d8ccf31ba521ea76a7153032f20d /tests | |
parent | 922e0979e2c27ff8dbc765ae151d17c7815b98a0 (diff) | |
download | sink-c90ba4a98292a39eb0b3df12fd7e2dec0300e58d.tar.gz sink-c90ba4a98292a39eb0b3df12fd7e2dec0300e58d.zip |
Move Key API into own files + some fixes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pipelinetest.cpp | 9 | ||||
-rw-r--r-- | tests/querytest.cpp | 38 | ||||
-rw-r--r-- | tests/storagetest.cpp | 1 |
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 | ||
24 | static void removeFromDisk(const QString &name) | 25 | static 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 | ||
1866 | QTEST_MAIN(QueryTest) | 1828 | 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 @@ | |||
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. |