aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_config.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-24 16:38:45 +0200
committerDanilo M. <danix@danix.xyz>2026-09-24 16:38:45 +0200
commit0ac517403ead1135bc5fe0e05c2b8b00382052ae (patch)
tree0112695473880aa173d5eb49928f15e23ce6e8f0 /tests/test_config.cpp
parent4818cf555141d83b0d8414c86c3b7aef26286dd3 (diff)
downloadqtmaildir-0ac517403ead1135bc5fe0e05c2b8b00382052ae.tar.gz
qtmaildir-0ac517403ead1135bc5fe0e05c2b8b00382052ae.zip
feat: read the calendar's config keys
Diffstat (limited to 'tests/test_config.cpp')
-rw-r--r--tests/test_config.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index 05ddbee..a713697 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -149,6 +149,9 @@ private slots:
void contactsDirIsActuallyRead();
void contactsDirExpandsATilde();
void contactsDirThatDoesNotExistIsReported();
+ void calendarKeysAreOffWithoutThem();
+ void calendarKeysAreRead();
+ void calendarSyncCommandSurvivesACommaAndDefaults();
};
static QString writeIni(const QTemporaryDir &dir, const QString &body)
@@ -2861,5 +2864,54 @@ void TestConfig::contactsDirThatDoesNotExistIsReported()
QCOMPARE(config.contactsDir(), missing);
}
+void TestConfig::calendarKeysAreOffWithoutThem()
+{
+ // Plan ruling 1: absent is OFF, silently, as contacts_dir is.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\n")));
+ QVERIFY(config.calendarsDir().isEmpty());
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::calendarKeysAreRead()
+{
+ QTemporaryDir dir;
+ const QString cal = dir.filePath(QStringLiteral("calendars"));
+ QDir().mkpath(cal);
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\n"
+ "calendars_dir = %1\n"
+ "default_calendar = 52\n"
+ "calendar_sync_delay_ms = 500\n").arg(cal)));
+ QCOMPARE(config.calendarsDir(), cal);
+ QCOMPARE(config.defaultCalendar(), QStringLiteral("52"));
+ QCOMPARE(config.calendarSyncDelayMs(), 500);
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::calendarSyncCommandSurvivesACommaAndDefaults()
+{
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\n")));
+ QCOMPARE(config.calendarSyncCommand(),
+ QStringLiteral("flock -w 60 /tmp/vdirsyncer.lock vdirsyncer sync calendars"));
+ QCOMPARE(config.calendarSyncDelayMs(), 2000);
+
+ // QSettings splits an unquoted value on commas into a QStringList, and
+ // toString() on a list is EMPTY: a command holding a comma would silently
+ // turn syncing off. The reader joins the list back.
+ Config commas;
+ commas.load(writeIni(dir, QStringLiteral("[general]\n"
+ "calendar_sync_command = mysync --only a,b\n")));
+ QCOMPARE(commas.calendarSyncCommand(), QStringLiteral("mysync --only a,b"));
+
+ // Written but empty disables, which is different from absent.
+ Config off;
+ off.load(writeIni(dir, QStringLiteral("[general]\ncalendar_sync_command = \n")));
+ QVERIFY(off.calendarSyncCommand().isEmpty());
+}
+
QTEST_MAIN(TestConfig)
#include "test_config.moc"