mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-21 08:58:29 -05:00
tom enhanced in unit tests check
Dropped a flag in the StatusCommand and used in unit tests flag defined in the TomApplication.
This commit is contained in:
@@ -317,6 +317,10 @@ namespace Concerns
|
||||
public:
|
||||
/*! Run the tom application with the given arguments (used in auto tests). */
|
||||
int runWithArguments(QStringList &&arguments);
|
||||
|
||||
private:
|
||||
/*! Is enabled logic for unit testing? */
|
||||
inline static bool inUnitTests() noexcept;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -145,6 +145,12 @@ namespace Commands
|
||||
/*! Get database connection resolver. */
|
||||
std::shared_ptr<ConnectionResolverInterface> connectionResolver() const noexcept;
|
||||
|
||||
/* Auto tests helpers */
|
||||
#ifdef TINYTOM_TESTS_CODE
|
||||
/*! Is enabled logic for unit testing? */
|
||||
bool inUnitTests() const noexcept;
|
||||
#endif
|
||||
|
||||
/* Data members */
|
||||
/*! Reference to the tom application. */
|
||||
std::reference_wrapper<Application> m_application;
|
||||
|
||||
@@ -61,8 +61,6 @@ namespace Commands::Migrations
|
||||
|
||||
/*! Get result of the status command (used in auto tests). */
|
||||
inline static std::vector<StatusRow> status();
|
||||
/*! Enable logic for unit testing? */
|
||||
inline static void setInUnitTests() noexcept;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
@@ -83,9 +81,6 @@ namespace Commands::Migrations
|
||||
/*! Result of the status command (used in auto tests). */
|
||||
T_THREAD_LOCAL
|
||||
inline static std::vector<StatusRow> m_status;
|
||||
/*! Is enabled logic for unit testing? */
|
||||
T_THREAD_LOCAL
|
||||
inline static auto m_inUnitTests = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -106,11 +101,6 @@ namespace Commands::Migrations
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
void StatusCommand::setInUnitTests() noexcept
|
||||
{
|
||||
m_inUnitTests = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace Commands::Migrations
|
||||
|
||||
@@ -261,8 +261,6 @@ std::vector<Application::StatusRow> Application::status()
|
||||
void Application::enableInUnitTests() noexcept
|
||||
{
|
||||
g_inUnitTests = true;
|
||||
|
||||
StatusCommand::setInUnitTests();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -828,6 +826,13 @@ int Application::runWithArguments(QStringList &&arguments)
|
||||
// Ownership of a unique_ptr()
|
||||
return createCommand(getCommandName())->runWithArguments(std::move(arguments));
|
||||
}
|
||||
|
||||
/* private */
|
||||
|
||||
bool Application::inUnitTests() noexcept
|
||||
{
|
||||
return g_inUnitTests;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace Tom
|
||||
|
||||
@@ -336,6 +336,15 @@ Command::connectionResolver() const noexcept
|
||||
return application().connectionResolver();
|
||||
}
|
||||
|
||||
/* Auto tests helpers */
|
||||
|
||||
#ifdef TINYTOM_TESTS_CODE
|
||||
bool Command::inUnitTests() const noexcept
|
||||
{
|
||||
return application().inUnitTests();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* private */
|
||||
|
||||
void Command::initializePositionalArguments()
|
||||
|
||||
@@ -73,7 +73,7 @@ int StatusCommand::run()
|
||||
/* During testing save the result of a status command to the global
|
||||
variable instead of outputting it, to be able to verify results. */
|
||||
#ifdef TINYTOM_TESTS_CODE
|
||||
if (m_inUnitTests)
|
||||
if (inUnitTests())
|
||||
m_status = statusForUnitTest(std::move(migrations));
|
||||
else
|
||||
#endif
|
||||
@@ -83,7 +83,7 @@ int StatusCommand::run()
|
||||
}
|
||||
|
||||
#ifdef TINYTOM_TESTS_CODE
|
||||
if (m_inUnitTests)
|
||||
if (inUnitTests())
|
||||
m_status.clear();
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user