Mock locating config file for wizard tests to be independent of Qt's behavior
Maybe overriding `HOME` is not sufficient for faking a different home dir to be picked up by `QStandardPaths`. So this change makes `LIB_SYNCTHING_CONNECTOR_SYNCTHING_CONFIG_DIR` a hard override and uses it in tests to fake a different path independently from the behavior of `QStandardPaths`.
This commit is contained in:
parent
860cf28e47
commit
0ab21657c4
|
@ -20,7 +20,10 @@ namespace Data {
|
|||
QString SyncthingConfig::locateConfigFile()
|
||||
{
|
||||
auto path = qEnvironmentVariable(PROJECT_VARNAME_UPPER "_SYNCTHING_CONFIG_DIR");
|
||||
if (!path.isEmpty() && QFile::exists(path += QStringLiteral("/config.xml"))) {
|
||||
if (!path.isEmpty()) {
|
||||
if (!QFile::exists(path += QStringLiteral("/config.xml"))) {
|
||||
path.clear();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("syncthing/config.xml"));
|
||||
|
|
|
@ -58,6 +58,7 @@ void WizardTests::initTestCase()
|
|||
// use an empty dir as HOME to simulate a prestine setup
|
||||
qDebug() << QStringLiteral("HOME dir: ") + m_homeDir.path();
|
||||
qputenv("HOME", m_homeDir.path().toLocal8Bit());
|
||||
qputenv("LIB_SYNCTHING_CONNECTOR_SYNCTHING_CONFIG_DIR", (m_homeDir.path() + QStringLiteral("/.config/syncthing")).toLocal8Bit());
|
||||
QVERIFY(m_homeDir.isValid());
|
||||
|
||||
// assert there's no connection setting present initially
|
||||
|
|
Loading…
Reference in New Issue