From 23b77f6faecd0b1ae6365946ecfdc3cf87ffe6c9 Mon Sep 17 00:00:00 2001 From: Jacyking <791026912@qq.com> Date: Tue, 11 Jul 2023 14:07:52 +0800 Subject: [PATCH] test create table with unique --- tests/test_ormpp.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/test_ormpp.cpp b/tests/test_ormpp.cpp index bad5672c..e7025ee5 100644 --- a/tests/test_ormpp.cpp +++ b/tests/test_ormpp.cpp @@ -878,17 +878,6 @@ TEST_CASE("orm_aop") { // REQUIRE(r); } -#ifdef ORMPP_ENABLE_SQLITE3 -TEST_CASE("test create table with unique") { - dbng sqlite; - if (sqlite.connect(db)) { - sqlite.execute("drop table if exists person"); - CHECK(sqlite.create_datatable(ormpp_auto_key{"id"}, - ormpp_unique{"name"})); - } -} -#endif - #ifdef ORMPP_ENABLE_MYSQL struct image { int id; @@ -961,4 +950,23 @@ TEST_CASE("orm_mysql_blob_tuple") { REQUIRE(img.bin.size() == size); REQUIRE(time == img_ex.time); } -#endif \ No newline at end of file +#endif + +TEST_CASE("test create table with unique") { +#ifdef ORMPP_ENABLE_MYSQL + dbng mysql; + if (mysql.connect(ip, "root", password, db)) { + mysql.execute("drop table if exists person"); + CHECK(mysql.create_datatable(ormpp_auto_key{"id"}, + ormpp_unique{"name"})); + } +#endif +#ifdef ORMPP_ENABLE_SQLITE3 + dbng sqlite; + if (sqlite.connect(db)) { + sqlite.execute("drop table if exists person"); + CHECK(sqlite.create_datatable(ormpp_auto_key{"id"}, + ormpp_unique{"name"})); + } +#endif +} \ No newline at end of file