diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-03 20:49:25 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-04 12:54:12 +0200 |
| commit | 8e65d8f5eba78acc9558e26f9b728521f323b1a6 (patch) | |
| tree | b757abae9cfe2a7797332e0190845edfb52ab0a6 /tests | |
| parent | 4175f3e7314410a5e35bb3c06a0faf9065ce2e7a (diff) | |
| download | qtmaildir-8e65d8f5eba78acc9558e26f9b728521f323b1a6.tar.gz qtmaildir-8e65d8f5eba78acc9558e26f9b728521f323b1a6.zip | |
feat(worker): list every tag in the database
Query bar completion cannot offer tag names without a way to enumerate
them, and libnotmuch had no call wired up for it. Follows the existing
generation-counter pattern; the result crosses the thread boundary as a
QStringList.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_notmuchworker.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_notmuchworker.cpp b/tests/test_notmuchworker.cpp index 699f72c..488b630 100644 --- a/tests/test_notmuchworker.cpp +++ b/tests/test_notmuchworker.cpp @@ -55,6 +55,9 @@ private slots: void applyTagsToThreadsSpansMultipleThreads(); void applyTagsToThreadsWithNoThreadsDoesNothing(); + void requestAllTagsReturnsSortedTags(); + void requestAllTagsOnUnreadableConfigEmitsError(); + private: /// Tags of one message, read back through a fresh worker query. QStringList tagsOf(const QString &messageId); @@ -433,5 +436,41 @@ void TestNotmuchWorker::applyTagsToThreadsWithNoThreadsDoesNothing() QVERIFY(errors.isEmpty()); } +void TestNotmuchWorker::requestAllTagsReturnsSortedTags() +{ + NotmuchWorker worker(m_fixture.configPath()); + QSignalSpy spy(&worker, &NotmuchWorker::allTagsReady); + + worker.requestAllTags(7); + + QCOMPARE(spy.count(), 1); + const QStringList tags = spy.at(0).at(0).toStringList(); + const quint64 generation = spy.at(0).at(1).value<quint64>(); + + QCOMPARE(generation, quint64(7)); + QVERIFY(tags.contains(QStringLiteral("inbox"))); + QVERIFY(tags.contains(QStringLiteral("unread"))); + + // Completion offers these in order, so the worker sorts once rather than + // every consumer sorting again. + QStringList sorted = tags; + sorted.sort(); + QCOMPARE(tags, sorted); +} + +void TestNotmuchWorker::requestAllTagsOnUnreadableConfigEmitsError() +{ + // Fails closed like every other entry point: never silently fall through to + // the user's real database. + NotmuchWorker worker(QStringLiteral("/nonexistent/qtmaildir-test/config")); + QSignalSpy ready(&worker, &NotmuchWorker::allTagsReady); + QSignalSpy errors(&worker, &NotmuchWorker::errorOccurred); + + worker.requestAllTags(1); + + QCOMPARE(errors.size(), 1); + QVERIFY(ready.isEmpty()); +} + QTEST_MAIN(TestNotmuchWorker) #include "test_notmuchworker.moc" |
