mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-12 20:38:56 -05:00
fixed tests after improved db connection code
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
#include <QtTest>
|
||||
|
||||
#include "orm/databaseconnection.hpp"
|
||||
#include "orm/grammar.hpp"
|
||||
#include "orm/query/querybuilder.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "database.hpp"
|
||||
|
||||
class tst_QueryBuilder : public QObject
|
||||
{
|
||||
@@ -12,21 +11,20 @@ class tst_QueryBuilder : public QObject
|
||||
|
||||
public:
|
||||
tst_QueryBuilder();
|
||||
~tst_QueryBuilder();
|
||||
~tst_QueryBuilder() = default;
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
void test_case1();
|
||||
|
||||
private:
|
||||
Orm::DatabaseConnection &m_db;
|
||||
};
|
||||
|
||||
tst_QueryBuilder::tst_QueryBuilder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
tst_QueryBuilder::~tst_QueryBuilder()
|
||||
: m_db(Utils::Database::createConnection())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QtTest>
|
||||
|
||||
#include "orm/databaseconnection.hpp"
|
||||
@@ -43,6 +44,6 @@ void tst_DatabaseConnection::pingDatabase()
|
||||
QVERIFY2(result, "Ping database failed.");
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_DatabaseConnection)
|
||||
QTEST_MAIN(tst_DatabaseConnection)
|
||||
|
||||
#include "tst_databaseconnection.moc"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QtTest>
|
||||
|
||||
#include "orm/grammar.hpp"
|
||||
@@ -8,7 +9,7 @@ class tst_Grammar : public QObject
|
||||
|
||||
public:
|
||||
tst_Grammar();
|
||||
~tst_Grammar();
|
||||
~tst_Grammar() = default;
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
@@ -23,11 +24,6 @@ tst_Grammar::tst_Grammar()
|
||||
|
||||
}
|
||||
|
||||
tst_Grammar::~tst_Grammar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void tst_Grammar::initTestCase()
|
||||
{
|
||||
|
||||
@@ -42,6 +38,6 @@ void tst_Grammar::test_case1()
|
||||
{
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_Grammar)
|
||||
QTEST_MAIN(tst_Grammar)
|
||||
|
||||
#include "tst_grammar.moc"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
include($$TINYORM_SOURCE_TREE/tests/config.pri)
|
||||
include($$TINYORM_SOURCE_TREE/tests/auto/utils.pri)
|
||||
|
||||
SOURCES = tst_querybuilder.cpp
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QtTest>
|
||||
|
||||
#include "orm/databaseconnection.hpp"
|
||||
#include "orm/grammar.hpp"
|
||||
#include "orm/query/querybuilder.hpp"
|
||||
|
||||
#include "database.hpp"
|
||||
|
||||
class tst_QueryBuilder : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QueryBuilder();
|
||||
~tst_QueryBuilder();
|
||||
~tst_QueryBuilder() = default;
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
@@ -19,17 +22,14 @@ private slots:
|
||||
void setDistinct();
|
||||
void setTable();
|
||||
void setFrom();
|
||||
|
||||
private:
|
||||
Orm::DatabaseConnection &m_db;
|
||||
};
|
||||
|
||||
tst_QueryBuilder::tst_QueryBuilder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
tst_QueryBuilder::~tst_QueryBuilder()
|
||||
{
|
||||
|
||||
}
|
||||
: m_db(Utils::Database::createConnection())
|
||||
{}
|
||||
|
||||
void tst_QueryBuilder::initTestCase()
|
||||
{
|
||||
@@ -43,8 +43,7 @@ void tst_QueryBuilder::cleanupTestCase()
|
||||
|
||||
void tst_QueryBuilder::setDistinct()
|
||||
{
|
||||
Orm::QueryBuilder builder(Orm::DatabaseConnection::instance(),
|
||||
Orm::Grammar());
|
||||
Orm::QueryBuilder builder(m_db, Orm::Grammar());
|
||||
|
||||
auto distinct = builder.getDistinct();
|
||||
QCOMPARE(distinct, false);
|
||||
@@ -57,8 +56,7 @@ void tst_QueryBuilder::setDistinct()
|
||||
|
||||
void tst_QueryBuilder::setTable()
|
||||
{
|
||||
Orm::QueryBuilder builder(Orm::DatabaseConnection::instance(),
|
||||
Orm::Grammar());
|
||||
Orm::QueryBuilder builder(m_db, Orm::Grammar());
|
||||
|
||||
auto table = builder.getTable();
|
||||
auto tableFrom = builder.getFrom();
|
||||
@@ -78,8 +76,7 @@ void tst_QueryBuilder::setTable()
|
||||
|
||||
void tst_QueryBuilder::setFrom()
|
||||
{
|
||||
Orm::QueryBuilder builder(Orm::DatabaseConnection::instance(),
|
||||
Orm::Grammar());
|
||||
Orm::QueryBuilder builder(m_db, Orm::Grammar());
|
||||
|
||||
auto table = builder.getTable();
|
||||
auto tableFrom = builder.getFrom();
|
||||
@@ -97,6 +94,6 @@ void tst_QueryBuilder::setFrom()
|
||||
QCOMPARE(tableFrom, newTableName);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QueryBuilder)
|
||||
QTEST_MAIN(tst_QueryBuilder)
|
||||
|
||||
#include "tst_querybuilder.moc"
|
||||
|
||||
Reference in New Issue
Block a user