diff --git a/swh/scrubber/tests/conftest.py b/swh/scrubber/tests/conftest.py --- a/swh/scrubber/tests/conftest.py +++ b/swh/scrubber/tests/conftest.py @@ -8,15 +8,14 @@ import pytest from pytest_postgresql import factories -from swh.core.db.pytest_plugin import initialize_database_for_module, postgresql_fact +from swh.core.db.pytest_plugin import initialize_database_for_module from swh.scrubber.db import ScrubberDb scrubber_postgresql_proc = factories.postgresql_proc( - dbname="scrubber", load=[partial(initialize_database_for_module, modname="scrubber", version=1)], ) -postgresql_scrubber = postgresql_fact("scrubber_postgresql_proc") +postgresql_scrubber = factories.postgresql("scrubber_postgresql_proc") @pytest.fixture diff --git a/swh/scrubber/tests/test_storage_postgresql.py b/swh/scrubber/tests/test_storage_postgresql.py --- a/swh/scrubber/tests/test_storage_postgresql.py +++ b/swh/scrubber/tests/test_storage_postgresql.py @@ -44,6 +44,7 @@ @pytest.mark.parametrize("corrupt_idx", range(len(swh_model_data.SNAPSHOTS))) @patch_byte_ranges def test_corrupt_snapshot(scrubber_db, swh_storage, corrupt_idx): + storage_dsn = swh_storage.get_db().conn.dsn snapshots = list(swh_model_data.SNAPSHOTS) snapshots[corrupt_idx] = attr.evolve(snapshots[corrupt_idx], id=b"\x00" * 20) swh_storage.snapshot_add(snapshots) @@ -66,9 +67,7 @@ ) assert corrupt_objects[0].datastore.package == "storage" assert corrupt_objects[0].datastore.cls == "postgresql" - assert corrupt_objects[0].datastore.instance.startswith( - "user=postgres password=xxx dbname=storage host=" - ) + assert corrupt_objects[0].datastore.instance.startswith(storage_dsn) assert ( before_date - datetime.timedelta(seconds=5) <= corrupt_objects[0].first_occurrence