mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-30 10:45:18 -06:00
Working C++ test. Now need to add the build logic and Docker magic
This commit is contained in:
@@ -1,6 +1,24 @@
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
#include "mysql_driver.h"
|
||||
#include <mysql/jdbc.h>
|
||||
|
||||
#define QUERIES_SIZE 5
|
||||
|
||||
std::string queries[QUERIES_SIZE] =
|
||||
{
|
||||
"create table test (pk int, value int, primary key(pk))",
|
||||
"describe test",
|
||||
"select * from test",
|
||||
"insert into test (pk, value) values (0,0)",
|
||||
"select * from test"
|
||||
};
|
||||
|
||||
int is_update[QUERIES_SIZE] = {0,0,0,1,0};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::string user = argv[1];
|
||||
@@ -8,10 +26,35 @@ int main(int argc, char **argv) {
|
||||
std::string db = argv[3];
|
||||
|
||||
sql::mysql::MySQL_Driver *driver;
|
||||
|
||||
sql::Connection *con;
|
||||
|
||||
driver = sql::mysql::get_mysql_driver_instance();
|
||||
con = driver->connect("tcp://127.0.0.1:" + port, user, "");
|
||||
con->setSchema(db);
|
||||
|
||||
for ( int i = 0; i < QUERIES_SIZE; i++ ) {
|
||||
try {
|
||||
sql::Statement *stmt = con->createStatement();
|
||||
|
||||
if ( is_update[i] ) {
|
||||
int affected_rows = stmt->executeUpdate(queries[i]);
|
||||
} else {
|
||||
sql::ResultSet *res = stmt->executeQuery(queries[i]);
|
||||
delete res;
|
||||
}
|
||||
|
||||
delete stmt;
|
||||
} catch (sql::SQLException &e) {
|
||||
std::cout << "QUERY: " << queries[i] << std::endl;
|
||||
std::cout << "# ERR: " << e.what();
|
||||
std::cout << " (MySQL error code: " << e.getErrorCode();
|
||||
std::cout << ", SQLState: " << e.getSQLState() << " )" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
delete con;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,7 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "cpp mysql connector" {
|
||||
(cd $BATS_TEST_DIRNAME/cpp; make clean; make)
|
||||
$BATS_TEST_DIRNAME/cpp/mysql-connector-cpp-test $USER $PORT $REPO_NAME
|
||||
$BATS_TEST_DIRNAME/cpp/_build/test_mysql_connector_cxx $USER $PORT $REPO_NAME
|
||||
}
|
||||
|
||||
@test "dotnet mysql connector" {
|
||||
|
||||
Reference in New Issue
Block a user