Skip to content

Commit

Permalink
tests extracted autotest skipped string
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Aug 19, 2022
1 parent 9487634 commit 3308f26
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 52 deletions.
9 changes: 9 additions & 0 deletions tests/TinyUtils/src/databases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ namespace Orm

namespace TestUtils
{
/* I will not create a separate constants file for these two constants, define them
here is ok because every test that will include databases.hpp will also use
one of these constants. */
inline const QString AutoTestSkipped =
QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.");
inline const QString AutoTestSkippedAny =
QStringLiteral("%1 autotest skipped, environment variables "
"for ANY connection have not been defined.");

class TINYUTILS_EXPORT Databases
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ void tst_QueryBuilder::initTestCase_data() const
const auto &connections = Databases::createConnections();

if (connections.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for ANY connection have not been defined.")
.arg("tst_QueryBuilder").toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkippedAny.arg("tst_QueryBuilder")
.toUtf8().constData(), );

QTest::addColumn<QString>("connection");

Expand Down
4 changes: 1 addition & 3 deletions tests/auto/functional/orm/tiny/model/tst_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ void tst_Model::initTestCase_data() const
const auto &connections = Databases::createConnections();

if (connections.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for ANY connection have not been defined.")
.arg("tst_Model").toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkippedAny.arg("tst_Model").toUtf8().constData(), );

QTest::addColumn<QString>("connection");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ void tst_Model_Connection_Independent::initTestCase()
Databases::createConnection(Databases::MYSQL);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
.arg("tst_Model_Connection_Independent",
Databases::MYSQL).toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkipped
.arg("tst_Model_Connection_Independent", Databases::MYSQL)
.toUtf8().constData(), );
}

void tst_Model_Connection_Independent::subscriptOperator() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,8 @@ void tst_Model_Relations::initTestCase_data() const
const auto &connections = Databases::createConnections();

if (connections.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for ANY connection have not been defined.")
.arg("tst_Model_Relations").toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkippedAny.arg("tst_Model_Relations")
.toUtf8().constData(), );

QTest::addColumn<QString>("connection");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ void tst_Relations_Connection_Independent::initTestCase()
Databases::createConnection(Databases::MYSQL);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
.arg("tst_Relations_Connection_Independent",
Databases::MYSQL).toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkipped
.arg("tst_Relations_Connection_Independent", Databases::MYSQL)
.toUtf8().constData(), );
}

/* HasOne */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ void tst_Relations_Inserting_Updating::initTestCase_data() const
const auto &connections = Databases::createConnections();

if (connections.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for ANY connection have not been defined.")
.arg("tst_Relations_Inserting_Updating").toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkippedAny.arg("tst_Relations_Inserting_Updating")
.toUtf8().constData(), );

QTest::addColumn<QString>("connection");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ void tst_TinyBuilder::initTestCase_data() const
const auto &connections = Databases::createConnections();

if (connections.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for ANY connection have not been defined.")
.arg("tst_TinyBuilder").toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkippedAny.arg("tst_TinyBuilder")
.toUtf8().constData(), );

QTest::addColumn<QString>("connection");

Expand Down
4 changes: 1 addition & 3 deletions tests/auto/functional/tom/migrate/tst_migrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ void tst_Migrate::initTestCase()
Databases::createConnections({Databases::MYSQL, Databases::POSTGRESQL});

if (connections.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for ANY connection have not been defined.")
.arg("tst_Migrate").toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkippedAny.arg("tst_Migrate").toUtf8().constData(), );

QTest::addColumn<QString>("connection");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ void tst_DatabaseConnection::initTestCase_data() const
const auto &connections = Databases::createConnections();

if (connections.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for ANY connection have not been defined.")
.arg("tst_DatabaseConnection").toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkippedAny.arg("tst_DatabaseConnection")
.toUtf8().constData(), );

QTest::addColumn<QString>("connection");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,8 @@ void tst_MySql_QueryBuilder::initTestCase()
m_connection = Databases::createConnection(Databases::MYSQL);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
.arg("tst_MySql_QueryBuilder", Databases::MYSQL).toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkipped.arg("tst_MySql_QueryBuilder", Databases::MYSQL)
.toUtf8().constData(), );
}

void tst_MySql_QueryBuilder::version() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ void tst_PostgreSQL_QueryBuilder::initTestCase()
m_connection = Databases::createConnection(Databases::POSTGRESQL);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
.arg("tst_PostgreSQL_QueryBuilder",
Databases::POSTGRESQL).toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkipped
.arg("tst_PostgreSQL_QueryBuilder", Databases::POSTGRESQL)
.toUtf8().constData(), );
}

void tst_PostgreSQL_QueryBuilder::get() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ void tst_SQLite_QueryBuilder::initTestCase()
m_connection = Databases::createConnection(Databases::SQLITE);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
.arg("tst_SQLite_QueryBuilder", Databases::SQLITE).toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkipped
.arg("tst_SQLite_QueryBuilder", Databases::SQLITE)
.toUtf8().constData(), );
}

void tst_SQLite_QueryBuilder::get() const
Expand Down
5 changes: 2 additions & 3 deletions tests/auto/unit/orm/schema/blueprint/tst_blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ void tst_Blueprint::initTestCase()
m_connection = Databases::createConnection(Databases::MYSQL);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
.arg("tst_Blueprint", Databases::MYSQL).toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkipped.arg("tst_Blueprint", Databases::MYSQL)
.toUtf8().constData(), );
}

void tst_Blueprint::index_DefaultNames() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ void tst_Mysql_SchemaBuilder::initTestCase()
m_connection = Databases::createConnection(Databases::MYSQL);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
.arg("tst_Mysql_SchemaBuilder", Databases::MYSQL).toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkipped.arg("tst_Mysql_SchemaBuilder", Databases::MYSQL)
.toUtf8().constData(), );
}

void tst_Mysql_SchemaBuilder::createDatabase() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ void tst_PostgreSQL_SchemaBuilder::initTestCase()
m_connection = Databases::createConnection(Databases::POSTGRESQL);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
QSKIP(TestUtils::AutoTestSkipped
.arg("tst_PostgreSQL_SchemaBuilder", Databases::POSTGRESQL)
.toUtf8().constData(), );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ void tst_SQLite_SchemaBuilder::initTestCase()
m_connection = Databases::createConnection(Databases::SQLITE);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
QSKIP(TestUtils::AutoTestSkipped
.arg("tst_SQLite_SchemaBuilder", Databases::SQLITE)
.toUtf8().constData(), );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ void tst_MySql_TinyBuilder::initTestCase()
m_connection = Databases::createConnection(Databases::MYSQL);

if (m_connection.isEmpty())
QSKIP(QStringLiteral("%1 autotest skipped, environment variables "
"for '%2' connection have not been defined.")
.arg("tst_MySql_TinyBuilder", Databases::MYSQL).toUtf8().constData(), );
QSKIP(TestUtils::AutoTestSkipped.arg("tst_MySql_TinyBuilder", Databases::MYSQL)
.toUtf8().constData(), );
}

void tst_MySql_TinyBuilder::has_Basic_OnHasMany() const
Expand Down

0 comments on commit 3308f26

Please sign in to comment.