Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristian König <ckoenig@posteo.de>2022-07-26 18:34:42 +0300
committerChristian König <ckoenig@posteo.de>2022-07-26 18:34:42 +0300
commitc8c4eb59b774de7ad7ae5b3afd017626de7c20f3 (patch)
treeb0b911574cfef232d6876d6adc8b55db05ba0893 /test
parent2651abbe6c0d2e834907d161af99606e706c4dba (diff)
Add getFTLPID() tests
Signed-off-by: Christian König <ckoenig@posteo.de>
Diffstat (limited to 'test')
-rw-r--r--test/test_any_utils.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/test/test_any_utils.py b/test/test_any_utils.py
index 8ec8871c..0668b9d1 100644
--- a/test/test_any_utils.py
+++ b/test/test_any_utils.py
@@ -77,8 +77,8 @@ def test_getFTLAPIPortFile_and_getFTLAPIPort_custom(host):
''')
output = host.run('''
source /opt/pihole/utils.sh
- FTL_API_PORT=$(getFTLAPIPortFile)
- getFTLAPIPort "${FTL_API_PORT}"
+ FTL_API_PORT_FILE=$(getFTLAPIPortFile)
+ getFTLAPIPort "${FTL_API_PORT_FILE}"
''')
expected_stdout = '1234\n'
assert expected_stdout == output.stdout
@@ -92,14 +92,26 @@ def test_getFTLPIDFile_default(host):
expected_stdout = '/run/pihole-FTL.pid\n'
assert expected_stdout == output.stdout
-def test_getFTLPIDFile_custom(host):
+def test_getFTLPID_default(host):
+ ''' Confirms getFTLPID returns the default value if FTL is not running '''
+ output = host.run('''
+ source /opt/pihole/utils.sh
+ getFTLPID
+ ''')
+ expected_stdout = '-1\n'
+ assert expected_stdout == output.stdout
+
+def test_getFTLPIDFile_and_getFTLPID_custom(host):
''' Confirms getFTLPIDFile returns a custom PID file path '''
host.run('''
echo "PIDFILE=/tmp/pid.file" > /etc/pihole/pihole-FTL.conf
+ echo "1234" > /tmp/pid.file
''')
output = host.run('''
source /opt/pihole/utils.sh
- getFTLPIDFile
+ FTL_PID_FILE=$(getFTLPIDFile)
+ getFTLPID "${FTL_PID_FILE}"
''')
expected_stdout = '/tmp/pid.file\n'
assert expected_stdout == output.stdout
+