Adjust test to mock PID1 to be systemd

Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
Christian König 2025-05-27 23:51:04 +02:00
parent 137338e6a8
commit f3166d7a78
No known key found for this signature in database
6 changed files with 14 additions and 12 deletions

View File

@ -1,7 +1,7 @@
FROM quay.io/centos/centos:stream10
# Disable SELinux
RUN echo "SELINUX=disabled" > /etc/selinux/config
RUN yum install -y --allowerasing curl git initscripts
RUN yum install -y --allowerasing curl git
ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole

View File

@ -1,7 +1,7 @@
FROM quay.io/centos/centos:stream9
# Disable SELinux
RUN echo "SELINUX=disabled" > /etc/selinux/config
RUN yum install -y --allowerasing curl git initscripts
RUN yum install -y --allowerasing curl git
ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole

View File

@ -1,5 +1,5 @@
FROM fedora:40
RUN dnf install -y git initscripts
RUN dnf install -y git
ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole

View File

@ -1,5 +1,5 @@
FROM fedora:41
RUN dnf install -y git initscripts
RUN dnf install -y git
ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole

View File

@ -1,5 +1,5 @@
FROM fedora:42
RUN dnf install -y git initscripts
RUN dnf install -y git
ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole

View File

@ -66,6 +66,14 @@ def test_installPihole_fresh_install_readableFiles(host):
mock_command("dialog", {"*": ("", "0")}, host)
# mock git pull
mock_command_passthrough("git", {"pull": ("", "0")}, host)
# mock PID 1 to pretend to be systemd
mock_command_2(
"ps",
{
"-p 1": ("systemd", "0"),
},
host,
)
# mock systemctl to not start FTL
mock_command_2(
"systemctl",
@ -73,6 +81,7 @@ def test_installPihole_fresh_install_readableFiles(host):
"enable pihole-FTL": ("", "0"),
"restart pihole-FTL": ("", "0"),
"start pihole-FTL": ("", "0"),
"stop pihole-FTL": ("", "0"),
"*": ('echo "systemctl call with $@"', "0"),
},
host,
@ -131,13 +140,6 @@ def test_installPihole_fresh_install_readableFiles(host):
check_macvendor = test_cmd.format("r", "/etc/pihole/macvendor.db", piholeuser)
actual_rc = host.run(check_macvendor).rc
assert exit_status_success == actual_rc
# check readable and executable /etc/init.d/pihole-FTL
check_init = test_cmd.format("x", "/etc/init.d/pihole-FTL", piholeuser)
actual_rc = host.run(check_init).rc
assert exit_status_success == actual_rc
check_init = test_cmd.format("r", "/etc/init.d/pihole-FTL", piholeuser)
actual_rc = host.run(check_init).rc
assert exit_status_success == actual_rc
# check readable and executable manpages
if maninstalled is True:
check_man = test_cmd.format("x", "/usr/local/share/man", piholeuser)