mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 12:00:37 +02:00
adding unittest to colnod project in auto subproject
This commit is contained in:
parent
d334007f6c
commit
26fbc9b7a5
4
test/auto/auto.pro
Normal file
4
test/auto/auto.pro
Normal file
@ -0,0 +1,4 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
database/tst_databaseapi.pro \
|
||||
24
test/auto/database/tst_databaseapi.cpp
Normal file
24
test/auto/database/tst_databaseapi.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <QtTest>
|
||||
|
||||
#include "databaseapi.h"
|
||||
// add necessary includes here
|
||||
|
||||
class DatabaseTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void open_database_test();
|
||||
|
||||
};
|
||||
|
||||
void DatabaseTest::open_database_test()
|
||||
{
|
||||
serversdk::DatabaseManager dbManager;
|
||||
DatabaseAPI db(&dbManager, false);
|
||||
|
||||
QVERIFY(!db.open());
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(DatabaseTest)
|
||||
|
||||
#include "tst_databaseapi.moc"
|
||||
11
test/auto/database/tst_databaseapi.pro
Normal file
11
test/auto/database/tst_databaseapi.pro
Normal file
@ -0,0 +1,11 @@
|
||||
QT += testlib
|
||||
QT -= gui
|
||||
|
||||
CONFIG += qt console warn_on depend_includepath testcase
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += tst_databaseapi.cpp
|
||||
|
||||
include(../../test.pri)
|
||||
34
test/test.cpp
Normal file
34
test/test.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "test.h"
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
/**
|
||||
* @brief Return path to source directory
|
||||
* @param subpath ( e.g. test/data )
|
||||
* @return absolute path to desired subpath in source folder
|
||||
*/
|
||||
QString Test::sourcePath(const QString &subpath)
|
||||
{
|
||||
const QString path = QStringLiteral(COLNOD_TEST_PATH);
|
||||
QDir dir(path);
|
||||
return dir.absoluteFilePath(subpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return data from source directory
|
||||
* @param subpath ( e.g. test/data/gizp.src )
|
||||
* @return data of file - QByteArray
|
||||
*/
|
||||
QByteArray Test::sourceData(const QString &subpath)
|
||||
{
|
||||
// Get data from file
|
||||
QString filePath = sourcePath(subpath);
|
||||
if (! QFileInfo::exists(filePath)) {
|
||||
qWarning() << "path does not exists:" << filePath;
|
||||
return QByteArray();
|
||||
}
|
||||
QFile file(filePath);
|
||||
if ( file.open(QIODevice::ReadOnly) )
|
||||
return file.readAll();
|
||||
return QByteArray();
|
||||
}
|
||||
12
test/test.h
Normal file
12
test/test.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
class Test
|
||||
{
|
||||
public:
|
||||
static QString sourcePath(const QString &subpath);
|
||||
static QByteArray sourceData(const QString &subpath);
|
||||
};
|
||||
|
||||
18
test/test.pri
Normal file
18
test/test.pri
Normal file
@ -0,0 +1,18 @@
|
||||
include(../serversdkint.pri)
|
||||
|
||||
COLNOD_ROOT=$$PWD/..
|
||||
COLNOD_TEST_PATH=$$SDK_ROOT/test/data
|
||||
|
||||
DEFINES += COLNOD_TEST_PATH='\\"$$COLNOD_TEST_PATH\\"'
|
||||
|
||||
QT += testlib
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/test.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/test.cpp
|
||||
|
||||
include(../src/colnod/colnod.pri)
|
||||
@ -1,5 +1,5 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
unitTests
|
||||
auto
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user