add a test
This commit is contained in:
parent
b49dafa7e3
commit
d17aa51abf
@ -64,6 +64,7 @@ private slots:
|
|||||||
|
|
||||||
void testHouseKeeping();
|
void testHouseKeeping();
|
||||||
|
|
||||||
|
void testLimits();
|
||||||
|
|
||||||
// this has to be the last test
|
// this has to be the last test
|
||||||
void removeDevice();
|
void removeDevice();
|
||||||
@ -593,6 +594,56 @@ void TestLogging::testHouseKeeping()
|
|||||||
QVERIFY2(response.toMap().value("params").toMap().value("logEntries").toList().count() == 0, "Device state change event still in log. Should've been cleaned by housekeeping.");
|
QVERIFY2(response.toMap().value("params").toMap().value("logEntries").toList().count() == 0, "Device state change event still in log. Should've been cleaned by housekeeping.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestLogging::testLimits()
|
||||||
|
{
|
||||||
|
clearLoggingDatabase();
|
||||||
|
|
||||||
|
for (int i = 0; i < 50; i++) {
|
||||||
|
QVariantList actionParams;
|
||||||
|
QVariantMap param1;
|
||||||
|
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||||
|
param1.insert("value", i);
|
||||||
|
actionParams.append(param1);
|
||||||
|
QVariantMap param2;
|
||||||
|
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||||
|
param2.insert("value", true);
|
||||||
|
actionParams.append(param2);
|
||||||
|
|
||||||
|
QVariantMap params;
|
||||||
|
params.insert("actionTypeId", mockActionIdWithParams);
|
||||||
|
params.insert("deviceId", m_mockDeviceId);
|
||||||
|
params.insert("params", actionParams);
|
||||||
|
|
||||||
|
// EXECUTE with params
|
||||||
|
QVariant response = injectAndWait("Actions.ExecuteAction", params);
|
||||||
|
verifyDeviceError(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap params;
|
||||||
|
QVariantMap response;
|
||||||
|
|
||||||
|
// No limits, should be all 50 entries
|
||||||
|
params.clear();
|
||||||
|
response = injectAndWait("Logging.GetLogEntries", params).toMap();
|
||||||
|
QCOMPARE(response.value("params").toMap().value("count").toInt(), 50);
|
||||||
|
QCOMPARE(response.value("params").toMap().value("logEntries").toList().count(), 50);
|
||||||
|
|
||||||
|
// Add a limit of 20
|
||||||
|
params.clear();
|
||||||
|
params.insert("limit", 20);
|
||||||
|
response = injectAndWait("Logging.GetLogEntries", params).toMap();
|
||||||
|
QCOMPARE(response.value("params").toMap().value("count").toInt(), 20);
|
||||||
|
QCOMPARE(response.value("params").toMap().value("logEntries").toList().count(), 20);
|
||||||
|
|
||||||
|
// Add a offset of 40, keeping a limit of 20. should return 10 entries
|
||||||
|
params.clear();
|
||||||
|
params.insert("limit", 20);
|
||||||
|
params.insert("offset", 40);
|
||||||
|
response = injectAndWait("Logging.GetLogEntries", params).toMap();
|
||||||
|
QCOMPARE(response.value("params").toMap().value("count").toInt(), 10);
|
||||||
|
QCOMPARE(response.value("params").toMap().value("logEntries").toList().count(), 10);
|
||||||
|
}
|
||||||
|
|
||||||
void TestLogging::removeDevice()
|
void TestLogging::removeDevice()
|
||||||
{
|
{
|
||||||
// enable notifications
|
// enable notifications
|
||||||
|
|||||||
Reference in New Issue
Block a user