summaryrefslogtreecommitdiffstats
path: root/tests/test_config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_config.cpp')
-rw-r--r--tests/test_config.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index 4d92891..dc85968 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -51,6 +51,8 @@ private slots:
void extraMimetypesAppendToBuiltins();
void extraMimetypeDescriptionMayContainComma();
void malformedExtraMimetypeIsSkipped();
+ void syncChannelDefaultsToTheAccountKey();
+ void syncChannelIsActuallyRead();
};
static QString writeIni(const QTemporaryDir &dir, const QString &body)
@@ -524,5 +526,36 @@ void TestConfig::malformedExtraMimetypeIsSkipped()
QVERIFY(!config.problems().isEmpty());
}
+void TestConfig::syncChannelDefaultsToTheAccountKey()
+{
+ // Most accounts name their mbsync channel exactly as their section key, so
+ // the common case must need no config edit at all.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[account.work]\n"
+ "maildir = work\n")));
+
+ QCOMPARE(config.accounts().size(), 1);
+ QCOMPARE(config.accounts().at(0).syncChannel(), QStringLiteral("work"));
+}
+
+void TestConfig::syncChannelIsActuallyRead()
+{
+ // The key exists because the two names genuinely diverge: a QSettings
+ // section key may carry dots that the mbsync channel does not, and passing
+ // the section key to mbsync would name a channel that does not exist.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[account.mail-first.last]\n"
+ "maildir = mail-first.last\n"
+ "channel = mail-firstlast\n")));
+
+ QCOMPARE(config.accounts().size(), 1);
+ QCOMPARE(config.accounts().at(0).syncChannel(),
+ QStringLiteral("mail-firstlast"));
+}
+
QTEST_MAIN(TestConfig)
#include "test_config.moc"