1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Don't allow in-memory SQLite database (#69616)

This commit is contained in:
Erik Montnemery
2022-04-08 00:43:09 +02:00
committed by GitHub
parent fab1f29a29
commit 949b0e1b65
8 changed files with 77 additions and 40 deletions

View File

@@ -910,10 +910,16 @@ def init_recorder_component(hass, add_config=None):
if recorder.CONF_COMMIT_INTERVAL not in config:
config[recorder.CONF_COMMIT_INTERVAL] = 0
with patch("homeassistant.components.recorder.migration.migrate_schema"):
with patch(
"homeassistant.components.recorder.ALLOW_IN_MEMORY_DB",
True,
), patch("homeassistant.components.recorder.migration.migrate_schema"):
assert setup_component(hass, recorder.DOMAIN, {recorder.DOMAIN: config})
assert recorder.DOMAIN in hass.config.components
_LOGGER.info("In-memory recorder successfully started")
_LOGGER.info(
"Test recorder successfully started, database location: %s",
config[recorder.CONF_DB_URL],
)
async def async_init_recorder_component(hass, add_config=None):
@@ -924,12 +930,18 @@ async def async_init_recorder_component(hass, add_config=None):
if recorder.CONF_COMMIT_INTERVAL not in config:
config[recorder.CONF_COMMIT_INTERVAL] = 0
with patch("homeassistant.components.recorder.migration.migrate_schema"):
with patch(
"homeassistant.components.recorder.ALLOW_IN_MEMORY_DB",
True,
), patch("homeassistant.components.recorder.migration.migrate_schema"):
assert await async_setup_component(
hass, recorder.DOMAIN, {recorder.DOMAIN: config}
)
assert recorder.DOMAIN in hass.config.components
_LOGGER.info("In-memory recorder successfully started")
_LOGGER.info(
"Test recorder successfully started, database location: %s",
config[recorder.CONF_DB_URL],
)
def mock_restore_cache(hass, states):