Skip to content

Commit

Permalink
Ensure addon.start always returns coroutine (#4409)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 authored Jun 27, 2023
1 parent 9fbeb2a commit c2123f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion supervisor/addons/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ async def start(self) -> Awaitable[None]:
"""
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)
Expand Down
19 changes: 19 additions & 0 deletions tests/addons/test_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c2123f0

Please sign in to comment.