Ensure addon.start always returns coroutine (#4409)

This commit is contained in:
Mike Degatano 2023-06-27 13:43:49 -04:00 committed by GitHub
parent 9fbeb2a769
commit c2123f0903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -716,7 +716,7 @@ class Addon(AddonModel):
"""
if await self.instance.is_running():
_LOGGER.warning("%s is already running!", self.slug)
return
return self._wait_for_startup()
# Access Token
self.persist[ATTR_ACCESS_TOKEN] = secrets.token_hex(56)

View File

@ -471,3 +471,22 @@ async def test_restore(
start_task = await coresys.addons.restore(TEST_ADDON_SLUG, tarfile)
assert bool(start_task) is (status == "running")
async def test_start_when_running(
coresys: CoreSys,
install_addon_ssh: Addon,
container: MagicMock,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test starting an addon without healthcheck."""
container.status = "running"
await install_addon_ssh.load()
assert install_addon_ssh.state == AddonState.STARTED
caplog.clear()
start_task = await install_addon_ssh.start()
assert start_task
await start_task
assert "local_ssh is already running" in caplog.text