add some configuration tests
This commit is contained in:
parent
6ebda18235
commit
a2ff8374c4
@ -40,8 +40,8 @@ class TestConfigurations: public GuhTestBase
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void getConfigurations();
|
void getConfigurations();
|
||||||
|
|
||||||
void testTimeZones();
|
void testTimeZones();
|
||||||
|
void testServerName();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -63,14 +63,80 @@ void TestConfigurations::getConfigurations()
|
|||||||
|
|
||||||
void TestConfigurations::testTimeZones()
|
void TestConfigurations::testTimeZones()
|
||||||
{
|
{
|
||||||
QVariantMap configurations = injectAndWait("Configuration.GetConfigurations").toMap().value("params").toMap();
|
QVariantMap params; QVariant response; QVariantMap configurations;
|
||||||
QString currentTimeZone = configurations.value("basicConfiguration").toMap().value("timeZone").toString();
|
|
||||||
QString currentTime = configurations.value("basicConfiguration").toMap().value("serverTime").toString();
|
|
||||||
qDebug() << currentTimeZone << QDateTime::fromTime_t(currentTime.toInt());
|
|
||||||
QVariantList timeZones = injectAndWait("Configuration.GetTimeZones").toMap().value("params").toMap().value("timeZones").toList();
|
QVariantList timeZones = injectAndWait("Configuration.GetTimeZones").toMap().value("params").toMap().value("timeZones").toList();
|
||||||
QVERIFY(timeZones.count() > 0);
|
QVERIFY(timeZones.count() > 0);
|
||||||
QVERIFY(timeZones.contains("America/Toronto"));
|
QVERIFY(timeZones.contains("America/Toronto"));
|
||||||
|
QVERIFY(timeZones.contains("Europe/Vienna"));
|
||||||
|
|
||||||
|
// Set current timezone (Europe/Vienna)
|
||||||
|
params.clear(); response.clear(); configurations.clear();
|
||||||
|
params.insert("timeZone", "Europe/Vienna");
|
||||||
|
response = injectAndWait("Configuration.SetTimeZone", params);
|
||||||
|
verifyConfigurationError(response);
|
||||||
|
|
||||||
|
// Get current timezone and time
|
||||||
|
params.clear(); response.clear(); configurations.clear();
|
||||||
|
configurations = injectAndWait("Configuration.GetConfigurations").toMap().value("params").toMap();
|
||||||
|
QString currentTimeZone = configurations.value("basicConfiguration").toMap().value("timeZone").toString();
|
||||||
|
int currentTime = configurations.value("basicConfiguration").toMap().value("serverTime").toInt();
|
||||||
|
qDebug() << currentTimeZone << QDateTime::fromTime_t(currentTime);
|
||||||
|
|
||||||
|
// Set new timezone
|
||||||
|
params.clear(); response.clear(); configurations.clear();
|
||||||
|
params.insert("timeZone", "Moon/Darkside");
|
||||||
|
response = injectAndWait("Configuration.SetTimeZone", params);
|
||||||
|
verifyConfigurationError(response, GuhConfiguration::ConfigurationErrorInvalidTimeZone);
|
||||||
|
|
||||||
|
// Set new timezone
|
||||||
|
params.clear(); response.clear(); configurations.clear();
|
||||||
|
params.insert("timeZone", "America/Toronto");
|
||||||
|
response = injectAndWait("Configuration.SetTimeZone", params);
|
||||||
|
verifyConfigurationError(response);
|
||||||
|
|
||||||
|
// Check new timezone
|
||||||
|
params.clear(); response.clear(); configurations.clear();
|
||||||
|
configurations = injectAndWait("Configuration.GetConfigurations").toMap().value("params").toMap();
|
||||||
|
QString newTimeZone = configurations.value("basicConfiguration").toMap().value("timeZone").toString();
|
||||||
|
int newTime = configurations.value("basicConfiguration").toMap().value("serverTime").toInt();
|
||||||
|
qDebug() << newTimeZone << QDateTime::fromTime_t(newTime);
|
||||||
|
QVERIFY(currentTimeZone != newTimeZone);
|
||||||
|
|
||||||
|
restartServer();
|
||||||
|
|
||||||
|
// Check loaded timezone
|
||||||
|
configurations = injectAndWait("Configuration.GetConfigurations").toMap().value("params").toMap();
|
||||||
|
QString reloadedTimeZone = configurations.value("basicConfiguration").toMap().value("timeZone").toString();
|
||||||
|
QVERIFY(newTimeZone == reloadedTimeZone);
|
||||||
|
|
||||||
|
params.clear(); response.clear();
|
||||||
|
params.insert("timeZone", "Europe/Vienna");
|
||||||
|
response = injectAndWait("Configuration.SetTimeZone", params);
|
||||||
|
verifyConfigurationError(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestConfigurations::testServerName()
|
||||||
|
{
|
||||||
|
QVariantMap params; QVariant response; QVariantMap configurations;
|
||||||
|
configurations = injectAndWait("Configuration.GetConfigurations").toMap().value("params").toMap();
|
||||||
|
QString serverName = configurations.value("basicConfiguration").toMap().value("serverName").toString();
|
||||||
|
QString serverUuid = configurations.value("basicConfiguration").toMap().value("serverUuid").toString();
|
||||||
|
qDebug() << "Server name" << serverName << "(" << serverUuid << ")";
|
||||||
|
|
||||||
|
params.insert("serverName", "Test server");
|
||||||
|
response = injectAndWait("Configuration.SetServerName", params);
|
||||||
|
verifyConfigurationError(response);
|
||||||
|
|
||||||
|
configurations = injectAndWait("Configuration.GetConfigurations").toMap().value("params").toMap();
|
||||||
|
QString newServerName = configurations.value("basicConfiguration").toMap().value("serverName").toString();
|
||||||
|
QVERIFY(newServerName == "Test server");
|
||||||
|
|
||||||
|
restartServer();
|
||||||
|
|
||||||
|
configurations = injectAndWait("Configuration.GetConfigurations").toMap().value("params").toMap();
|
||||||
|
QString reloadedServerName = configurations.value("basicConfiguration").toMap().value("serverName").toString();
|
||||||
|
QVERIFY(newServerName == reloadedServerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "testconfigurations.moc"
|
#include "testconfigurations.moc"
|
||||||
|
|||||||
@ -145,6 +145,10 @@ protected:
|
|||||||
verifyError(response, "loggingError", JsonTypes::loggingErrorToString(error));
|
verifyError(response, "loggingError", JsonTypes::loggingErrorToString(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void verifyConfigurationError(const QVariant &response, GuhConfiguration::ConfigurationError error = GuhConfiguration::ConfigurationErrorNoError) {
|
||||||
|
verifyError(response, "configurationError", JsonTypes::configurationErrorToString(error));
|
||||||
|
}
|
||||||
|
|
||||||
inline void verifyParams(const QVariantList &requestList, const QVariantList &responseList, bool allRequired = true)
|
inline void verifyParams(const QVariantList &requestList, const QVariantList &responseList, bool allRequired = true)
|
||||||
{
|
{
|
||||||
if (allRequired)
|
if (allRequired)
|
||||||
|
|||||||
Reference in New Issue
Block a user