Skip to content

Commit

Permalink
Add test for SystemdService.exists
Browse files Browse the repository at this point in the history
  • Loading branch information
CarstenGrohmann committed Jan 23, 2024
1 parent c535cc7 commit cb46ffa
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,37 @@ def test_systeminfo(host, docker_image):
@all_images
def test_ssh_service(host, docker_image):
service_name = ssh_pkg_info[docker_image][2]
ssh = host.service(service_name)
ssh_svc = host.service(service_name)
# wait at max 10 seconds for ssh is running
for _ in range(10):
if ssh.is_running:
if ssh_svc.is_running:
break
time.sleep(1)
else:
raise AssertionError("ssh is not running")

assert ssh.is_enabled
assert ssh_svc.is_enabled


@all_images
def test_systemdservice_exists(host, docker_image):
service_name = ssh_pkg_info[docker_image][2]
for name in [service_name, f"{service_name}.service"]:
ssh_svc = host.service(name)
assert ssh_svc.exists

for name in ["non-existing", "non-existing.service", "non-existing.timer"]:
non_existing_service = host.service(name)
assert not non_existing_service.exists


def test_service_systemd_mask(host):
ssh = host.service("ssh")
assert not ssh.is_masked
ssh_svc = host.service("ssh")
assert not ssh_svc.is_masked
host.run("systemctl mask ssh")
assert ssh.is_masked
assert ssh_svc.is_masked
host.run("systemctl unmask ssh")
assert not ssh.is_masked
assert not ssh_svc.is_masked


def test_salt(host):
Expand Down

0 comments on commit cb46ffa

Please sign in to comment.