1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Add CI job which runs recorder tests on PostgreSQL (#80614)

Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Erik Montnemery
2023-02-07 16:46:14 +01:00
committed by GitHub
parent 3a83b2f66f
commit 720f51657d
10 changed files with 187 additions and 41 deletions

View File

@@ -90,9 +90,15 @@ async def test_purge_old_states(
assert "test.recorder2" in instance._old_states
states_after_purge = session.query(States)
assert states_after_purge[1].old_state_id == states_after_purge[0].state_id
assert states_after_purge[0].old_state_id is None
states_after_purge = list(session.query(States))
# Since these states are deleted in batches, we can't guarantee the order
# but we can look them up by state
state_map_by_state = {state.state: state for state in states_after_purge}
dontpurgeme_5 = state_map_by_state["dontpurgeme_5"]
dontpurgeme_4 = state_map_by_state["dontpurgeme_4"]
assert dontpurgeme_5.old_state_id == dontpurgeme_4.state_id
assert dontpurgeme_4.old_state_id is None
finished = purge_old_data(instance, purge_before, repack=False)
assert finished
@@ -140,7 +146,7 @@ async def test_purge_old_states_encouters_database_corruption(
recorder_db_url: str,
):
"""Test database image image is malformed while deleting old states."""
if recorder_db_url.startswith("mysql://"):
if recorder_db_url.startswith(("mysql://", "postgresql://")):
# This test is specific for SQLite, wiping the database on error only happens
# with SQLite.
return