Add PGSql tests

This commit is contained in:
2026-04-29 23:49:07 -04:00
parent 68724dff8f
commit e09625c466
9 changed files with 453 additions and 6 deletions
+62 -5
View File
@@ -1,11 +1,47 @@
function(_cppbessot_db_action_test_common_args out_var test_name script_name)
set(_args
"-DCPPBESSOT_TEST_NAME=${test_name}"
"-DCPPBESSOT_TEST_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
"-DCPPBESSOT_TEST_MODULE_SOURCE_DIR=${PROJECT_SOURCE_DIR}"
"-DCPPBESSOT_DB_ACTION_TEST_PGSQL_ADMIN_CONNSTR=${CPPBESSOT_DB_ACTION_TEST_PGSQL_ADMIN_CONNSTR}"
"-DCPPBESSOT_DB_PGSQL_DEV_CONNSTR=${CPPBESSOT_DB_PGSQL_DEV_CONNSTR}"
"-DCPPBESSOT_DB_PGSQL_PROD_CONNSTR=${CPPBESSOT_DB_PGSQL_PROD_CONNSTR}"
"-DCPPBESSOT_DB_PGSQL_PRODDEV_CONNSTR=${CPPBESSOT_DB_PGSQL_PRODDEV_CONNSTR}"
"-DCPPBESSOT_DB_ACTION_TEST_SCRIPT=${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script_name}")
set(${out_var} "${_args}" PARENT_SCOPE)
endfunction()
function(cppbessot_add_db_action_test test_name script_name)
_cppbessot_db_action_test_common_args(_test_args "${test_name}" "${script_name}")
add_test(
NAME ${test_name}
COMMAND "${CMAKE_COMMAND}"
"-DCPPBESSOT_TEST_NAME=${test_name}"
"-DCPPBESSOT_TEST_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
"-DCPPBESSOT_TEST_MODULE_SOURCE_DIR=${PROJECT_SOURCE_DIR}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script_name}")
COMMAND "${CMAKE_COMMAND}" ${_test_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script_name}")
endfunction()
function(cppbessot_add_real_pgsql_db_action_test test_name script_name)
find_program(_psql psql)
if(NOT _psql)
message(STATUS "Skipping real PostgreSQL db-action test `${test_name}` because `psql` is not available.")
return()
endif()
if("${CPPBESSOT_DB_ACTION_TEST_PGSQL_ADMIN_CONNSTR}" STREQUAL "")
message(STATUS "Skipping real PostgreSQL db-action test `${test_name}` because CPPBESSOT_DB_ACTION_TEST_PGSQL_ADMIN_CONNSTR is empty.")
return()
endif()
foreach(_required_var IN LISTS ARGN)
if("${${_required_var}}" STREQUAL "")
message(STATUS "Skipping real PostgreSQL db-action test `${test_name}` because ${_required_var} is empty.")
return()
endif()
endforeach()
_cppbessot_db_action_test_common_args(_test_args "${test_name}" "${script_name}")
add_test(
NAME ${test_name}
COMMAND "${CMAKE_COMMAND}" ${_test_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script_name}")
set_tests_properties(${test_name} PROPERTIES RUN_SERIAL TRUE)
endfunction()
cppbessot_add_db_action_test(cppbessot_db_action_invalid_target invalid_target.cmake)
@@ -23,4 +59,25 @@ cppbessot_add_db_action_test(cppbessot_db_action_pgsql_createfrom_mock pgsql_cre
cppbessot_add_db_action_test(cppbessot_db_action_pgsql_migrate_order pgsql_migrate_order.cmake)
cppbessot_add_db_action_test(cppbessot_db_action_pgsql_stale_abort pgsql_stale_abort.cmake)
cppbessot_add_db_action_test(cppbessot_db_action_backfill_env_no_structural backfill_env_no_structural.cmake)
cppbessot_add_real_pgsql_db_action_test(
cppbessot_db_action_pgsql_createfrom_real
pgsql_createfrom_real.cmake
CPPBESSOT_DB_PGSQL_DEV_CONNSTR)
cppbessot_add_real_pgsql_db_action_test(
cppbessot_db_action_pgsql_migrate_real
pgsql_migrate_real.cmake
CPPBESSOT_DB_PGSQL_DEV_CONNSTR)
cppbessot_add_real_pgsql_db_action_test(
cppbessot_db_action_pgsql_proddev_clone_real
pgsql_proddev_clone_real.cmake
CPPBESSOT_DB_PGSQL_PROD_CONNSTR
CPPBESSOT_DB_PGSQL_PRODDEV_CONNSTR)
cppbessot_add_real_pgsql_db_action_test(
cppbessot_db_action_pgsql_proddev_stale_real
pgsql_proddev_stale_real.cmake
CPPBESSOT_DB_PGSQL_PRODDEV_CONNSTR)
cppbessot_add_real_pgsql_db_action_test(
cppbessot_db_action_pgsql_backfill_real
pgsql_backfill_real.cmake
CPPBESSOT_DB_PGSQL_DEV_CONNSTR)
cppbessot_add_db_action_test(cppbessot_db_action_regression regression_targets.cmake)