summaryrefslogtreecommitdiffstats
path: root/tests/querytest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-04 17:12:02 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-04 17:12:02 +0200
commit3ae3ef9676bd7fdcb45064f9a1b397c90478b4b7 (patch)
tree5ac341b501dae0a5e7d5addb8114535de53979cf /tests/querytest.cpp
parent7757d32b5a820623c469b7851354374427142598 (diff)
downloadsink-3ae3ef9676bd7fdcb45064f9a1b397c90478b4b7.tar.gz
sink-3ae3ef9676bd7fdcb45064f9a1b397c90478b4b7.zip
Resource subqueries
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r--tests/querytest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index 6011a99..6348316 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -528,6 +528,36 @@ private slots:
528 QCOMPARE(mails.size(), 1); 528 QCOMPARE(mails.size(), 1);
529 QCOMPARE(mails.first().getUid().toLatin1(), QByteArray("mail1")); 529 QCOMPARE(mails.first().getUid().toLatin1(), QByteArray("mail1"));
530 } 530 }
531
532 void testResourceSubQuery()
533 {
534 using namespace Sink;
535 using namespace Sink::ApplicationDomain;
536
537 //Setup
538 auto resource1 = ApplicationDomainType::createEntity<SinkResource>();
539 resource1.setResourceType("sink.dummy");
540 resource1.setCapabilities(QByteArrayList() << "cap1");
541 Store::create(resource1).exec().waitForFinished();
542
543 auto resource2 = ApplicationDomainType::createEntity<SinkResource>();
544 resource2.setCapabilities(QByteArrayList() << "cap2");
545 resource2.setResourceType("sink.dummy");
546 Store::create(resource2).exec().waitForFinished();
547
548 Folder folder1(resource1.identifier());
549 VERIFYEXEC(Sink::Store::create<Folder>(folder1));
550 Folder folder2(resource2.identifier());
551 VERIFYEXEC(Sink::Store::create<Folder>(folder2));
552
553 // Test
554 Sink::Query query;
555 query.filter<Folder::Resource>(Sink::Query().containsFilter<SinkResource::Capabilities>("cap1"));
556
557 // We fetch before the data is available and rely on the live query mechanism to deliver the actual data
558 auto folders = Sink::Store::read<Folder>(query);
559 QCOMPARE(folders.size(), 1);
560 }
531}; 561};
532 562
533QTEST_MAIN(QueryTest) 563QTEST_MAIN(QueryTest)