mirror of
https://gitlab.com/spaceti-app/integrations/common/server-sdk.git
synced 2026-07-12 16:00:37 +02:00
58 lines
943 B
C++
58 lines
943 B
C++
#include <QtTest>
|
|
|
|
#include "serversdk/databasemanager.h"
|
|
// add necessary includes here
|
|
|
|
class SqliteTest : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
SqliteTest();
|
|
~SqliteTest();
|
|
|
|
private slots:
|
|
void createDb_test();
|
|
|
|
};
|
|
|
|
SqliteTest::SqliteTest()
|
|
{
|
|
|
|
}
|
|
|
|
SqliteTest::~SqliteTest()
|
|
{
|
|
|
|
}
|
|
|
|
void SqliteTest::createDb_test()
|
|
{
|
|
// Prepare temporary path for database
|
|
QTemporaryDir dir;
|
|
Q_ASSERT(dir.isValid());
|
|
QString dbpath = dir.path() + "/testdb.sqlite";
|
|
Q_ASSERT(!dbpath.isEmpty());
|
|
Q_ASSERT(!QFileInfo::exists(dbpath));
|
|
|
|
serversdk::DatabaseManager db;
|
|
db.openSQLite(dbpath);
|
|
Q_ASSERT(db.isValid());
|
|
Q_ASSERT(db.isOpen());
|
|
Q_ASSERT(QFileInfo::exists(dbpath));
|
|
|
|
// Closing database
|
|
db.close();
|
|
Q_ASSERT(!db.isOpen());
|
|
|
|
|
|
// Temporary dir cleanup
|
|
Q_ASSERT(dir.remove());
|
|
|
|
Q_ASSERT(!QFileInfo::exists(dbpath));
|
|
}
|
|
|
|
QTEST_APPLESS_MAIN(SqliteTest)
|
|
|
|
#include "tst_sqlite.moc"
|