Always use a commit interval of 0 for the in memory db in tests (#69556)
This commit is contained in:
parent
5c7c09726a
commit
0ad9da9dd0
2 changed files with 9 additions and 5 deletions
|
@ -1119,8 +1119,7 @@ class Recorder(threading.Thread):
|
|||
self.event_session.add(dbstate)
|
||||
dbstate.event = dbevent
|
||||
|
||||
# If they do not have a commit interval
|
||||
# than we commit right away
|
||||
# Commit right away if the commit interval is zero
|
||||
if not self.commit_interval:
|
||||
self._commit_event_session_or_retry()
|
||||
|
||||
|
|
|
@ -905,7 +905,10 @@ def assert_setup_component(count, domain=None):
|
|||
def init_recorder_component(hass, add_config=None):
|
||||
"""Initialize the recorder."""
|
||||
config = dict(add_config) if add_config else {}
|
||||
config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB
|
||||
if recorder.CONF_DB_URL not in config:
|
||||
config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB
|
||||
if recorder.CONF_COMMIT_INTERVAL not in config:
|
||||
config[recorder.CONF_COMMIT_INTERVAL] = 0
|
||||
|
||||
with patch("homeassistant.components.recorder.migration.migrate_schema"):
|
||||
assert setup_component(hass, recorder.DOMAIN, {recorder.DOMAIN: config})
|
||||
|
@ -915,9 +918,11 @@ def init_recorder_component(hass, add_config=None):
|
|||
|
||||
async def async_init_recorder_component(hass, add_config=None):
|
||||
"""Initialize the recorder asynchronously."""
|
||||
config = add_config or {recorder.CONF_COMMIT_INTERVAL: 0}
|
||||
config = dict(add_config) if add_config else {}
|
||||
if recorder.CONF_DB_URL not in config:
|
||||
config[recorder.CONF_DB_URL] = "sqlite://"
|
||||
config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB
|
||||
if recorder.CONF_COMMIT_INTERVAL not in config:
|
||||
config[recorder.CONF_COMMIT_INTERVAL] = 0
|
||||
|
||||
with patch("homeassistant.components.recorder.migration.migrate_schema"):
|
||||
assert await async_setup_component(
|
||||
|
|
Loading…
Add table
Reference in a new issue