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