Skip to content
Merged
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
5 changes: 4 additions & 1 deletion testgen/common/standalone_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions tests/unit/common/test_standalone_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading