mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-25 14:07:44 -05:00
Report database read failure reason in tests
This commit is contained in:
parent
bef7ba2cfe
commit
564188b0d3
@ -65,12 +65,15 @@ void TestKeePass2Writer::initTestCase()
|
|||||||
buffer.open(QBuffer::ReadWrite);
|
buffer.open(QBuffer::ReadWrite);
|
||||||
|
|
||||||
KeePass2Writer writer;
|
KeePass2Writer writer;
|
||||||
writer.writeDatabase(&buffer, m_dbOrg);
|
bool writeSuccess = writer.writeDatabase(&buffer, m_dbOrg);
|
||||||
|
QVERIFY(writeSuccess);
|
||||||
QVERIFY(!writer.hasError());
|
QVERIFY(!writer.hasError());
|
||||||
buffer.seek(0);
|
buffer.seek(0);
|
||||||
KeePass2Reader reader;
|
KeePass2Reader reader;
|
||||||
m_dbTest = reader.readDatabase(&buffer, key);
|
m_dbTest = reader.readDatabase(&buffer, key);
|
||||||
QVERIFY(!reader.hasError());
|
if (reader.hasError()) {
|
||||||
|
QFAIL(reader.errorString().toUtf8().constData());
|
||||||
|
}
|
||||||
QVERIFY(m_dbTest);
|
QVERIFY(m_dbTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,12 +153,19 @@ void TestKeys::testCreateAndOpenFileKey()
|
|||||||
|
|
||||||
KeePass2Writer writer;
|
KeePass2Writer writer;
|
||||||
writer.writeDatabase(&dbBuffer, dbOrg.data());
|
writer.writeDatabase(&dbBuffer, dbOrg.data());
|
||||||
|
bool writeSuccess = writer.writeDatabase(&dbBuffer, dbOrg.data());
|
||||||
|
if (writer.hasError()) {
|
||||||
|
QFAIL(writer.errorString().toUtf8().constData());
|
||||||
|
}
|
||||||
|
QVERIFY(writeSuccess);
|
||||||
dbBuffer.reset();
|
dbBuffer.reset();
|
||||||
|
|
||||||
KeePass2Reader reader;
|
KeePass2Reader reader;
|
||||||
QScopedPointer<Database> dbRead(reader.readDatabase(&dbBuffer, compositeKey));
|
QScopedPointer<Database> dbRead(reader.readDatabase(&dbBuffer, compositeKey));
|
||||||
|
if (reader.hasError()) {
|
||||||
|
QFAIL(reader.errorString().toUtf8().constData());
|
||||||
|
}
|
||||||
QVERIFY(dbRead);
|
QVERIFY(dbRead);
|
||||||
QVERIFY(!reader.hasError());
|
|
||||||
QCOMPARE(dbRead->metadata()->name(), dbName);
|
QCOMPARE(dbRead->metadata()->name(), dbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user