mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Ensure recorder shuts down when its startup future is canceled out from under it (#72866)
This commit is contained in:
@@ -118,6 +118,26 @@ async def test_shutdown_before_startup_finishes(
|
||||
assert run_info.end is not None
|
||||
|
||||
|
||||
async def test_canceled_before_startup_finishes(
|
||||
hass: HomeAssistant,
|
||||
async_setup_recorder_instance: SetupRecorderInstanceT,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
):
|
||||
"""Test recorder shuts down when its startup future is canceled out from under it."""
|
||||
hass.state = CoreState.not_running
|
||||
await async_setup_recorder_instance(hass)
|
||||
instance = get_instance(hass)
|
||||
await instance.async_db_ready
|
||||
instance._hass_started.cancel()
|
||||
with patch.object(instance, "engine"):
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_add_executor_job(instance.join)
|
||||
assert (
|
||||
"Recorder startup was externally canceled before it could complete"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
|
||||
async def test_shutdown_closes_connections(hass, recorder_mock):
|
||||
"""Test shutdown closes connections."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user