mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-22 13:35:30 +01:00
Run Data/MySQL on AppVeyor
Signed-off-by: FrancisANDRE <zosrothko@orange.fr>
This commit is contained in:
parent
0708ba1392
commit
3e47ae2fb1
@ -13,6 +13,7 @@
|
||||
#include "MySQLTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Environment.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/Tuple.h"
|
||||
@ -33,6 +34,7 @@ using Poco::Data::MySQL::ConnectionException;
|
||||
using Poco::Data::MySQL::Utility;
|
||||
using Poco::Data::MySQL::StatementException;
|
||||
using Poco::format;
|
||||
using Poco::Environment;
|
||||
using Poco::NotFoundException;
|
||||
using Poco::Int32;
|
||||
using Poco::Nullable;
|
||||
@ -44,21 +46,37 @@ Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = 0;
|
||||
|
||||
//
|
||||
// Parameters for barebone-test
|
||||
#define MYSQL_USER "root"
|
||||
#define MYSQL_PWD "poco"
|
||||
#define MYSQL_HOST "localhost"
|
||||
#define MYSQL_PORT 3306
|
||||
#define MYSQL_DB "pocotestdb"
|
||||
|
||||
std::string MySQLTest::getHost()
|
||||
{
|
||||
return "localhost";
|
||||
}
|
||||
std::string MySQLTest::getPort()
|
||||
{
|
||||
return "3306";
|
||||
}
|
||||
std::string MySQLTest::getUser()
|
||||
{
|
||||
return "root";
|
||||
}
|
||||
std::string MySQLTest::getPass()
|
||||
{
|
||||
if (Environment::has("APPVEYOR"))
|
||||
return "Password12!";
|
||||
else
|
||||
return "poco";
|
||||
}
|
||||
std::string MySQLTest::getBase()
|
||||
{
|
||||
return "pocotestdb";
|
||||
}
|
||||
|
||||
std::string MySQLTest::_dbConnString;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Connection string
|
||||
std::string MySQLTest::_dbConnString = "host=" MYSQL_HOST
|
||||
";user=" MYSQL_USER
|
||||
";password=" MYSQL_PWD
|
||||
";db=" MYSQL_DB
|
||||
";compress=true"
|
||||
";auto-reconnect=true"
|
||||
";secure-auth=true";
|
||||
|
||||
|
||||
MySQLTest::MySQLTest(const std::string& name):
|
||||
@ -84,17 +102,18 @@ void MySQLTest::dbInfo(Session& session)
|
||||
|
||||
void MySQLTest::connectNoDB()
|
||||
{
|
||||
std::string dbConnString = "host=" MYSQL_HOST
|
||||
";user=" MYSQL_USER
|
||||
";password=" MYSQL_PWD
|
||||
";compress=true;auto-reconnect=true";
|
||||
std::string dbConnString;
|
||||
dbConnString = "host=" + getHost();
|
||||
dbConnString += ";user=" + getUser();
|
||||
dbConnString += ";password=" + getPass();
|
||||
dbConnString += ";compress=true;auto-reconnect=true";
|
||||
|
||||
try
|
||||
{
|
||||
Session session(MySQL::Connector::KEY, dbConnString);
|
||||
std::cout << "Connected to [" << "MySQL" << "] without database." << std::endl;
|
||||
dbInfo(session);
|
||||
session << "CREATE DATABASE IF NOT EXISTS " MYSQL_DB ";", now;
|
||||
session << "CREATE DATABASE IF NOT EXISTS " + getBase() + ";", now;
|
||||
std::cout << "Disconnecting ..." << std::endl;
|
||||
session.close();
|
||||
std::cout << "Disconnected." << std::endl;
|
||||
@ -117,7 +136,7 @@ void MySQLTest::testBareboneMySQL()
|
||||
"Fourth INTEGER,"
|
||||
"Fifth FLOAT)";
|
||||
|
||||
_pExecutor->bareboneMySQLTest(MYSQL_HOST, MYSQL_USER, MYSQL_PWD, MYSQL_DB, MYSQL_PORT, tableCreateString.c_str());
|
||||
_pExecutor->bareboneMySQLTest(getHost(), getUser(), getPass(), getBase(), getPort(), tableCreateString.c_str());
|
||||
}
|
||||
|
||||
|
||||
@ -837,6 +856,14 @@ CppUnit::Test* MySQLTest::suite()
|
||||
{
|
||||
MySQL::Connector::registerConnector();
|
||||
|
||||
_dbConnString = "host=" + getHost();
|
||||
_dbConnString += ";user=" + getUser();
|
||||
_dbConnString += ";password=" + getPass();
|
||||
_dbConnString += ";db=" + getBase();
|
||||
_dbConnString += ";compress=true";
|
||||
_dbConnString += ";auto-reconnect=true";
|
||||
_dbConnString += ";secure-auth=true";
|
||||
|
||||
try
|
||||
{
|
||||
_pSession = new Session(MySQL::Connector::KEY, _dbConnString);
|
||||
|
@ -128,6 +128,11 @@ private:
|
||||
|
||||
static void dbInfo(Poco::Data::Session& session);
|
||||
|
||||
static std::string getHost();
|
||||
static std::string getPort();
|
||||
static std::string getUser();
|
||||
static std::string getPass();
|
||||
static std::string getBase();
|
||||
static std::string _dbConnString;
|
||||
static Poco::SharedPtr<Poco::Data::Session> _pSession;
|
||||
static Poco::SharedPtr<SQLExecutor> _pExecutor;
|
||||
|
@ -27,10 +27,6 @@
|
||||
#include "Poco/Data/MySQL/Connector.h"
|
||||
#include "Poco/Data/MySQL/MySQLException.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <mysql.h>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
@ -155,13 +151,13 @@ SQLExecutor::~SQLExecutor()
|
||||
}
|
||||
|
||||
|
||||
void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const char* pwd, const char* db, int port, const char* tableCreateString)
|
||||
void SQLExecutor::bareboneMySQLTest(const std::string& host, const std::string& user, const std::string& pwd, const std::string& db, const std::string& port, const char* tableCreateString)
|
||||
{
|
||||
int rc;
|
||||
MYSQL* hsession = mysql_init(0);
|
||||
assert (hsession != 0);
|
||||
|
||||
MYSQL* tmp = mysql_real_connect(hsession, host, user, pwd, db, port, 0, 0);
|
||||
MYSQL* tmp = mysql_real_connect(hsession, host.c_str(), user.c_str(), pwd.c_str(), db.c_str(), stoi(port), 0, 0);
|
||||
assert(tmp == hsession);
|
||||
|
||||
MYSQL_STMT* hstmt = mysql_stmt_init(hsession);
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
SQLExecutor(const std::string& name, Poco::Data::Session* _pSession);
|
||||
~SQLExecutor();
|
||||
|
||||
void bareboneMySQLTest(const char* host, const char* user, const char* pwd, const char* db, int port, const char* tableCreateString);
|
||||
void bareboneMySQLTest(const std::string& host, const std::string& user, const std::string& pwd, const std::string& db, const std::string& port, const char* tableCreateString);
|
||||
/// This function uses "bare bone" MySQL API calls (i.e. calls are not
|
||||
/// "wrapped" in PocoData framework structures).
|
||||
/// The purpose of the function is to verify that driver behaves
|
||||
|
13
appveyor.yml
13
appveyor.yml
@ -330,10 +330,16 @@ build_script:
|
||||
}
|
||||
|
||||
before_test:
|
||||
# -------------------------------------------------------------------------------------------
|
||||
# MySQL
|
||||
- ps: |
|
||||
$env:MYSQL_PWD="Password12!"
|
||||
$cmd = 'mysql -e "create database pocotestdb;" --user=root';
|
||||
iex "& $cmd"
|
||||
|
||||
# -------------------------------------------------------------------------------------------
|
||||
# PostgreSQL
|
||||
- set PATH=C:\Program Files\PostgreSQL\9.4\bin\;%PATH%
|
||||
# -------------------------------------------------------------------------------------------
|
||||
|
||||
- ps: |
|
||||
$line='-------------------------------------------------------------------------------------';
|
||||
@ -352,6 +358,7 @@ before_test:
|
||||
|
||||
after_test:
|
||||
|
||||
|
||||
test_script:
|
||||
- ps: |
|
||||
$runs=0;$fails=0;$failedTests='';$status=0;$tab="`t";
|
||||
@ -364,12 +371,12 @@ test_script:
|
||||
if ($env:platform -eq "Win32")
|
||||
{
|
||||
$env:PATH = "$env:POCO_BASE\bin;" + $env:PATH;$suffix = '';
|
||||
$excluded = @('Data', 'Data/MySQL', 'Data/ODBC','Data/PostgreSQL', 'Redis', 'PDF')
|
||||
$excluded = @('Data', 'Data/ODBC','Data/PostgreSQL', 'Redis', 'PDF')
|
||||
}
|
||||
if ($env:platform -eq "x64")
|
||||
{
|
||||
$env:PATH = "$env:POCO_BASE\bin64;" + $env:PATH;$suffix = 64;
|
||||
$excluded = @('Data', 'Data/MySQL', 'Data/ODBC','Redis', 'PDF')
|
||||
$excluded = @('Data', 'Data/ODBC','Redis', 'PDF')
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Yellow '>>> current directory is ' $(get-location).Path;
|
||||
|
Loading…
x
Reference in New Issue
Block a user