diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-12 14:00:54 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-12 14:00:54 +0200 |
commit | d3cb4e649177443e8ecfd7f86d136fc0a319e2f3 (patch) | |
tree | 5a873b810944e1998b8f472db6c59fcc7e307863 /tests/querytest.cpp | |
parent | 8730949269771ad4d6bba9ba2414d272f9a0a799 (diff) | |
download | sink-d3cb4e649177443e8ecfd7f86d136fc0a319e2f3.tar.gz sink-d3cb4e649177443e8ecfd7f86d136fc0a319e2f3.zip |
Don't add resources that don't match the query during a livequery
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 72eca86..4ff1be8 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -625,6 +625,41 @@ private slots: | |||
625 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 625 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
626 | auto folders = Sink::Store::read<Folder>(Sink::Query{}.resourceContainsFilter<SinkResource::Capabilities>("cap1")); | 626 | auto folders = Sink::Store::read<Folder>(Sink::Query{}.resourceContainsFilter<SinkResource::Capabilities>("cap1")); |
627 | QCOMPARE(folders.size(), 1); | 627 | QCOMPARE(folders.size(), 1); |
628 | |||
629 | //TODO this should be part of the regular cleanup between tests | ||
630 | VERIFYEXEC(Store::remove(resource1)); | ||
631 | VERIFYEXEC(Store::remove(resource2)); | ||
632 | } | ||
633 | |||
634 | void testFilteredLiveResourceSubQuery() | ||
635 | { | ||
636 | using namespace Sink; | ||
637 | using namespace Sink::ApplicationDomain; | ||
638 | |||
639 | //Setup | ||
640 | auto resource1 = ApplicationDomainType::createEntity<SinkResource>(); | ||
641 | resource1.setResourceType("sink.dummy"); | ||
642 | resource1.setCapabilities(QByteArrayList() << "cap1"); | ||
643 | VERIFYEXEC(Store::create(resource1)); | ||
644 | VERIFYEXEC(Store::create<Folder>(Folder{resource1.identifier()})); | ||
645 | VERIFYEXEC(ResourceControl::flushMessageQueue(resource1.identifier())); | ||
646 | |||
647 | auto model = Sink::Store::loadModel<Folder>(Query{Query::LiveQuery}.resourceContainsFilter<SinkResource::Capabilities>("cap1")); | ||
648 | QTRY_COMPARE(model->rowCount(), 1); | ||
649 | |||
650 | auto resource2 = ApplicationDomainType::createEntity<SinkResource>(); | ||
651 | resource2.setCapabilities(QByteArrayList() << "cap2"); | ||
652 | resource2.setResourceType("sink.dummy"); | ||
653 | VERIFYEXEC(Store::create(resource2)); | ||
654 | VERIFYEXEC(Store::create<Folder>(Folder{resource2.identifier()})); | ||
655 | VERIFYEXEC(ResourceControl::flushMessageQueue(resource2.identifier())); | ||
656 | |||
657 | //The new resource should be filtered and thus not make it in here | ||
658 | QCOMPARE(model->rowCount(), 1); | ||
659 | |||
660 | //TODO this should be part of the regular cleanup between tests | ||
661 | VERIFYEXEC(Store::remove(resource1)); | ||
662 | VERIFYEXEC(Store::remove(resource2)); | ||
628 | } | 663 | } |
629 | 664 | ||
630 | void testLivequeryUnmatchInThread() | 665 | void testLivequeryUnmatchInThread() |