Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ if(BUILD_TESTS)
find_package(Qt${QT_VERSION_MAJOR} ${minReqQtVersion} REQUIRED COMPONENTS Test)

add_subdirectory(tests)

configure_file(CTestCustom.cmake.in CTestCustom.cmake @ONLY)
endif()

# Build examples
Expand Down
14 changes: 14 additions & 0 deletions CTestCustom.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if(DEFINED ENV{DB_AUTOMIGRATE})
if(DEFINED ENV{DB_MYSQL_DATABASE})
execute_process(COMMAND @CMAKE_COMMAND@ --build . --target tom_testdata_migrate_mysql COMMAND_ECHO STDOUT)
endif()
if(DEFINED ENV{DB_POSTGRES_DATABASE})
execute_process(COMMAND @CMAKE_COMMAND@ --build . --target tom_testdata_migrate_postgres COMMAND_ECHO STDOUT)
endif()
if(DEFINED ENV{DB_SQLITE_DATABASE})
execute_process(COMMAND @CMAKE_COMMAND@ --build . --target tom_testdata_migrate_sqlite COMMAND_ECHO STDOUT)
endif()
else()
message("DB_AUTOMIGRATE not set, skipping automigration")
endif()

9 changes: 9 additions & 0 deletions tests/testdata_tom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,12 @@ if(NOT STRICT_MODE)
endif()

target_link_libraries(${TomTestData_target} PRIVATE ${TinyOrm_ns}::${TinyOrm_target})


# All unit tests are functional only if the test databases are migrated prior to test execution.
#
# These targets are provided in order to simplify test setup
# ---
add_custom_target(tom_testdata_migrate_mysql COMMAND tom_testdata migrate:fresh --database=tinyorm_testdata_tom_mysql --seed --no-ansi DEPENDS ${TomTestData_target})
add_custom_target(tom_testdata_migrate_postgres COMMAND tom_testdata migrate:fresh --database=tinyorm_testdata_tom_postgres --seed --no-ansi DEPENDS ${TomTestData_target})
add_custom_target(tom_testdata_migrate_sqlite COMMAND tom_testdata migrate:fresh --database=tinyorm_testdata_tom_sqlite --seed --no-ansi DEPENDS ${TomTestData_target})