diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-24 16:41:09 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-24 16:41:09 +0200 |
| commit | 55eb08f9e03cc56c4d0e26a6c88e6ecc7222e1f3 (patch) | |
| tree | 03d4dcdc2c9753d60e94fe579526b7e0da410368 /tests/test_config.cpp | |
| parent | 0ac517403ead1135bc5fe0e05c2b8b00382052ae (diff) | |
| download | qtmaildir-55eb08f9e03cc56c4d0e26a6c88e6ecc7222e1f3.tar.gz qtmaildir-55eb08f9e03cc56c4d0e26a6c88e6ecc7222e1f3.zip | |
test: pin the calendar config's reported error paths
Diffstat (limited to 'tests/test_config.cpp')
| -rw-r--r-- | tests/test_config.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp index a713697..be343d1 100644 --- a/tests/test_config.cpp +++ b/tests/test_config.cpp @@ -152,6 +152,8 @@ private slots: void calendarKeysAreOffWithoutThem(); void calendarKeysAreRead(); void calendarSyncCommandSurvivesACommaAndDefaults(); + void calendarsDirThatDoesNotExistIsReported(); + void calendarSyncDelayRejectsGarbage(); }; static QString writeIni(const QTemporaryDir &dir, const QString &body) @@ -2913,5 +2915,53 @@ void TestConfig::calendarSyncCommandSurvivesACommaAndDefaults() QVERIFY(off.calendarSyncCommand().isEmpty()); } +void TestConfig::calendarsDirThatDoesNotExistIsReported() +{ + // The same line contacts_dir draws: a path the user wrote that is not + // there is something they asked for and are not getting, so it is + // reported. The value is KEPT, because a vdirsyncer target may not exist + // until its first run and the accessor should still say what was asked for. + QTemporaryDir dir; + const QString missing = dir.filePath(QStringLiteral("no-such-calendars")); + Config config; + config.load(writeIni(dir, QStringLiteral("[general]\n" + "calendars_dir=%1\n") + .arg(missing))); + + QVERIFY2(!config.problems().isEmpty(), + "a configured but missing calendars directory must be reported"); + const QString joined = config.problems().join(QLatin1Char('\n')); + QVERIFY2(joined.contains(missing), + "the warning must name the path the user wrote"); + QCOMPARE(config.calendarsDir(), missing); + + // A leading "~" is expanded, like contacts_dir, and the report names the + // EXPANDED path. This pins the expansion: a bare "~/..." kept literally + // would mention the tilde instead and this fails. + QTemporaryDir other; + Config nested; + const QString sub = QStringLiteral(".qtmaildir-test-no-such-calendars"); + nested.load(writeIni(other, QStringLiteral("[general]\n" + "calendars_dir=~/%1\n") + .arg(sub))); + const QString expanded = QDir::homePath() + QLatin1Char('/') + sub; + QCOMPARE(nested.calendarsDir(), expanded); + QVERIFY2(nested.problems().join(QLatin1Char('\n')).contains(expanded), + "the warning must name the tilde-expanded path"); +} + +void TestConfig::calendarSyncDelayRejectsGarbage() +{ + // Present but unparseable is a problem: the user asked for something and + // is not getting it, so it falls back to the default and says so, matching + // mark_read_delay_ms and auto_sync_delay_ms. + QTemporaryDir dir; + Config config; + config.load(writeIni(dir, QStringLiteral("[general]\n" + "calendar_sync_delay_ms=abc\n"))); + QCOMPARE(config.calendarSyncDelayMs(), 2000); + QVERIFY(!config.problems().isEmpty()); +} + QTEST_MAIN(TestConfig) #include "test_config.moc" |
