From 2651abbe6c0d2e834907d161af99606e706c4dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 26 Jul 2022 16:57:06 +0200 Subject: [PATCH] Add tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- test/test_any_utils.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/test_any_utils.py b/test/test_any_utils.py index aaa496cc..8ec8871c 100644 --- a/test/test_any_utils.py +++ b/test/test_any_utils.py @@ -49,6 +49,15 @@ def test_key_removal_works(host): expected_stdout = 'KEY_ONE=value1\nKEY_THREE=value3\n' assert expected_stdout == output.stdout +def test_getFTLAPIPortFile_default(host): + ''' Confirms getFTLAPIPortFile returns the default API port file path ''' + output = host.run(''' + source /opt/pihole/utils.sh + getFTLAPIPortFile + ''') + expected_stdout = '/run/pihole-FTL.port\n' + assert expected_stdout == output.stdout + def test_getFTLAPIPort_default(host): ''' Confirms getFTLAPIPort returns the default API port ''' @@ -73,3 +82,24 @@ def test_getFTLAPIPortFile_and_getFTLAPIPort_custom(host): ''') expected_stdout = '1234\n' assert expected_stdout == output.stdout + +def test_getFTLPIDFile_default(host): + ''' Confirms getFTLPIDFile returns the default PID file path ''' + output = host.run(''' + source /opt/pihole/utils.sh + getFTLPIDFile + ''') + expected_stdout = '/run/pihole-FTL.pid\n' + assert expected_stdout == output.stdout + +def test_getFTLPIDFile_custom(host): + ''' Confirms getFTLPIDFile returns a custom PID file path ''' + host.run(''' + echo "PIDFILE=/tmp/pid.file" > /etc/pihole/pihole-FTL.conf + ''') + output = host.run(''' + source /opt/pihole/utils.sh + getFTLPIDFile + ''') + expected_stdout = '/tmp/pid.file\n' + assert expected_stdout == output.stdout