diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-27 18:59:21 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-27 18:59:21 +0100 |
commit | d74a7b7aec40d83b940dbfe10850734075aa6c5c (patch) | |
tree | b1e0050b6265b068956ae7d417e1d5d8baf7a985 /test | |
parent | Basic type mapper (diff) | |
download | mygrate-d74a7b7aec40d83b940dbfe10850734075aa6c5c.tar.bz2 mygrate-d74a7b7aec40d83b940dbfe10850734075aa6c5c.tar.xz mygrate-d74a7b7aec40d83b940dbfe10850734075aa6c5c.zip |
Add an existing table to the config
Diffstat (limited to 'test')
-rw-r--r-- | test/Jamfile.jam | 2 | ||||
-rw-r--r-- | test/sql/createTestTable.sql | 14 | ||||
-rw-r--r-- | test/sql/selectTestTable.sql | 2 | ||||
-rw-r--r-- | test/test-e2e.cpp | 9 |
4 files changed, 27 insertions, 0 deletions
diff --git a/test/Jamfile.jam b/test/Jamfile.jam index d0b0e70..8486a14 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -8,6 +8,7 @@ project : requirements ; lib testdb : + [ glob-tree *.sql : bin ] [ glob testdb-*.cpp ] : <link>static ; @@ -18,4 +19,5 @@ run test-streams.cpp ; run test-misc.cpp ; run test-mysql.cpp : : : <library>testdb ; run test-postgresql.cpp : -- : ../db/schema.sql : <library>testdb ; +run test-e2e.cpp : -- : ../db/schema.sql : <library>testdb <implicit-dependency>testdb ; run test-mapping.cpp : : : <library>testdb <implicit-dependency>testdb ; diff --git a/test/sql/createTestTable.sql b/test/sql/createTestTable.sql new file mode 100644 index 0000000..fdc1c06 --- /dev/null +++ b/test/sql/createTestTable.sql @@ -0,0 +1,14 @@ +CREATE TABLE session( + id int(10) unsigned not null auto_increment, + session_id varchar(255) not null, + username varchar(10) not null collate utf8_bin, + user_lvl enum('standard', 'reseller', 'sysadmin', 'groupadm') not null default 'standard', + ip_addr varchar(255) not null, + port varchar(255) not null, + created datetime not null, + modified datetime not null, + last_action varchar(255) null default null, + + constraint `PRIMARY` primary key(id), + constraint session_id unique(session_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/test/sql/selectTestTable.sql b/test/sql/selectTestTable.sql new file mode 100644 index 0000000..2543786 --- /dev/null +++ b/test/sql/selectTestTable.sql @@ -0,0 +1,2 @@ +SELECT id, session_id, user_lvl, ip_addr, port, created, modified, last_action +FROM testout.session diff --git a/test/test-e2e.cpp b/test/test-e2e.cpp index fe57e17..9906a0b 100644 --- a/test/test-e2e.cpp +++ b/test/test-e2e.cpp @@ -1,9 +1,12 @@ #define BOOST_TEST_MODULE EndToEnd +#include <boost/test/data/test_case.hpp> #include <boost/test/unit_test.hpp> #include "testdb-mysql.h" #include "testdb-postgresql.h" #include <output/pq/updateDatabase.h> +#include <sql/createTestTable.h> +#include <sql/selectTestTable.h> BOOST_AUTO_TEST_CASE(e2e) { @@ -13,10 +16,16 @@ BOOST_AUTO_TEST_CASE(e2e) PqConnDB pq {ROOT "/db/schema.sql"}; auto pqm = pq.mock(); + auto mym = my.mock(); auto out = MyGrate::Output::Pq::UpdateDatabase::createNew(&pqm, MySQLDB::SERVER, MySQLDB::USER, MySQLDB::PASSWORD, MySQLDB::PORT, my.mockname.c_str(), 100, target_schema); BOOST_CHECK_EQUAL(out.source, 1); auto src = out.getSource(); BOOST_REQUIRE(src); + + MyGrate::sql::createTestTable::execute(&mym); + out.addTable(&mym, "session"); + + BOOST_CHECK_EQUAL(MyGrate::sql::selectTestTable::execute(&pqm)->rows(), 0); } |