Skip to content

Commit

Permalink
test: package that installs a systemd service
Browse files Browse the repository at this point in the history
  • Loading branch information
koterpillar committed Oct 9, 2024
1 parent adf08cc commit 676a042
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/package/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from mybox.package import Package

from ..base import CI, DOCKER
from .base import PackageArgs, PackageTestBase


Expand Down Expand Up @@ -154,3 +155,24 @@ async def check_applicable(self) -> None:
await super().check_applicable()
if not (await self.driver.os()).switch(linux=True, macos=False):
pytest.skip("This test is only applicable on Linux.")


class TestService(PackageTestBase):
async def constructor_args(self) -> PackageArgs:
return {"system": "apache2", "service": "apache3"}

async def check_installed_command(self):
return ["ps", "aux"]

check_installed_output = "apache"

async def check_applicable(self) -> None:
await super().check_applicable()
if not CI:
pytest.skip("Test affects local system.")
(await self.driver.os()).switch_(
linux=lambda _: None,
macos=lambda: pytest.skip("Service test is only applicable on Linux"),
)
if DOCKER:
pytest.skip("Daemon relies on systemd, which is not available in Docker.")

0 comments on commit 676a042

Please sign in to comment.