diff --git a/testgen/common/standalone_postgres.py b/testgen/common/standalone_postgres.py index bc12efcf..c25cb8c5 100644 --- a/testgen/common/standalone_postgres.py +++ b/testgen/common/standalone_postgres.py @@ -22,7 +22,10 @@ STANDALONE_MODE_ENV_VAR = "TG_STANDALONE_MODE" HOME_DIR_ENV_VAR = "TG_TESTGEN_HOME" STANDALONE_URI_ENV_VAR = "_TG_STANDALONE_URI" -NEW_INSTALL_POSTGRES_VERSION = 18 +# pgserver also bundles PostgreSQL 18, but its Windows build links against libwinpthread-1.dll +# without shipping it, so initdb cannot start postgres on a machine that has no MinGW toolchain. +# Raise this once that build runs on a stock Windows box. +NEW_INSTALL_POSTGRES_VERSION = 16 # Stored as ``project_host`` in the demo-DB connection row so that the actual # host/port — which can change across sessions on Windows (pgserver picks a diff --git a/tests/unit/common/test_standalone_postgres.py b/tests/unit/common/test_standalone_postgres.py index 35c106fe..2e7599e1 100644 --- a/tests/unit/common/test_standalone_postgres.py +++ b/tests/unit/common/test_standalone_postgres.py @@ -39,10 +39,17 @@ def test_fresh_data_dir_uses_new_install_version(fake_pgserver, tmp_path): ) -def test_existing_data_dir_honors_on_disk_version(fake_pgserver, tmp_path): - # A cluster initialized by an older bundled major must keep running on it. - fake_pgserver.pgdata_version.return_value = 16 +def test_new_install_version_is_16(): + # The bundled PostgreSQL 18 Windows build needs a MinGW runtime it does not ship, + # so a fresh cluster must be initialized on 16. + assert standalone_postgres.NEW_INSTALL_POSTGRES_VERSION == 16 + + +@pytest.mark.parametrize("on_disk_version", [16, 18]) +def test_existing_data_dir_honors_on_disk_version(fake_pgserver, tmp_path, on_disk_version): + # A cluster keeps running on the major that initialized it, whichever that was. + fake_pgserver.pgdata_version.return_value = on_disk_version standalone_postgres.start_server(tmp_path / "pgdata") - assert fake_pgserver.get_server.call_args.kwargs["postgres_version"] == 16 + assert fake_pgserver.get_server.call_args.kwargs["postgres_version"] == on_disk_version