Tidying up the tests

This commit is contained in:
Aleksandar Fabijanic
2007-05-23 01:06:46 +00:00
parent 2fe37eab6f
commit 418bb651c1
16 changed files with 248 additions and 107 deletions

View File

@@ -788,12 +788,12 @@ void ODBCMySQLTest::recreateVectorsTable()
}
bool ODBCMySQLTest::checkODBCSetup(const std::string& dbName)
bool ODBCMySQLTest::canConnect(const std::string& driver, const std::string& dsn)
{
Utility::DriverMap::iterator itDrv = _drivers.begin();
for (; itDrv != _drivers.end(); ++itDrv)
{
if (((itDrv->first).find(dbName) != std::string::npos))
if (((itDrv->first).find(driver) != std::string::npos))
{
std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl;
@@ -803,15 +803,30 @@ bool ODBCMySQLTest::checkODBCSetup(const std::string& dbName)
if (_drivers.end() == itDrv)
{
std::cout << dbName << " driver NOT found, tests not available." << std::endl;
std::cout << driver << " driver NOT found, tests not available." << std::endl;
return false;
}
_dbConnString = "DRIVER=MySQL ODBC 3.51 Driver;"
Utility::DSNMap dataSources;
Utility::dataSources(dataSources);
Utility::DSNMap::iterator itDSN = dataSources.begin();
for (; itDSN != dataSources.end(); ++itDSN)
{
if (itDSN->first == dsn && itDSN->second == driver)
{
std::cout << "DSN found: " << itDSN->first
<< " (" << itDSN->second << ')' << std::endl;
format(_dbConnString, "DSN=%s", dsn);
return true;
}
}
// DSN not found, try connect without it
format(_dbConnString, "DRIVER=%s;"
"DATABASE=test;"
"SERVER=localhost;"
"UID=root;"
"PWD=mysql;";
"PWD=mysql;", driver);
return true;
}
@@ -829,10 +844,10 @@ void ODBCMySQLTest::tearDown()
}
bool ODBCMySQLTest::init(const std::string& dbName)
bool ODBCMySQLTest::init(const std::string& driver, const std::string& dsn)
{
Utility::drivers(_drivers);
if (!checkODBCSetup()) return false;
if (!canConnect(driver, dsn)) return false;
ODBC::Connector::registerConnector();
try
@@ -845,9 +860,9 @@ bool ODBCMySQLTest::init(const std::string& dbName)
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << dbName << " test database." << std::endl;
std::cout << "*** Connected to [" << driver << "] test database." << std::endl;
_pExecutor = new SQLExecutor(dbName + " SQL Executor", _pSession);
_pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession);
return true;
}
@@ -855,7 +870,7 @@ bool ODBCMySQLTest::init(const std::string& dbName)
CppUnit::Test* ODBCMySQLTest::suite()
{
if (init())
if (init("MySQL ODBC 3.51 Driver", "PocoDataMySQLTest"))
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCMySQLTest");